Skip to content

Commit 5ca4495

Browse files
committed
posix setpgid: dont write null byte
1 parent e85eeb9 commit 5ca4495

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎cpp/implicitly_defined.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// # Implicitly defined functions
22
//
3+
// - https://stackoverflow.com/questions/3734247/what-are-all-the-member-functions-created-by-compiler-for-a-class-does-that-hap/53316960#53316960
34
// - https://stackoverflow.com/questions/4943958/conditions-for-automatic-generation-of-default-copy-move-ctor-and-copy-move-assi/53315860#53315860
5+
// - https://stackoverflow.com/questions/6502828/what-does-default-mean-after-a-class-function-declaration/53317010#53317010
46
// - https://stackoverflow.com/questions/12340257/default-vs-implicit-constructor-in-c
57
// - https://blog.mozilla.org/nfroyd/2015/08/20/explicit-is-better-than-implicit-c-implicitly-defined-member-functions/
6-
// - https://stackoverflow.com/questions/3734247/what-are-all-the-member-functions-created-by-compiler-for-a-class-does-that-hap
7-
// - https://stackoverflow.com/questions/4943958/conditions-for-automatic-generation-of-default-copy-move-ctor-and-copy-move-assi
88
// - https://en.cppreference.com/w/cpp/language/copy_constructor
99
// - https://en.cppreference.com/w/cpp/language/move_constructor
1010
// - https://en.cppreference.com/w/cpp/language/copy_assignment

‎cpp/pod.cpp‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ int main() {
219219
static_assert(std::is_pod<int>(), "");
220220
}
221221

222+
// Array of POD is POD.
223+
{
224+
struct C {};
225+
static_assert(std::is_pod<C>(), "");
226+
static_assert(std::is_pod<C[]>(), "");
227+
}
228+
222229
// Private member: became POD in C++11
223230
// https://stackoverflow.com/questions/4762788/can-a-class-with-all-private-members-be-a-pod-class/4762944#4762944
224231
{
@@ -233,9 +240,8 @@ int main() {
233240
#endif
234241
}
235242

236-
// Standard library containers are not, for the most part (all?),
237-
// POD because they are not trivial, which can be seen directly from their
238-
// interface definition in the standard.
243+
// Most standard library containers are not POD because they are not trivial,
244+
// which can be seen directly from their interface definition in the standard.
239245
// https://stackoverflow.com/questions/27165436/pod-implications-for-a-struct-which-holds-an-standard-library-container
240246
{
241247
static_assert(!std::is_pod<std::vector<int>>(), "");
@@ -244,13 +250,6 @@ int main() {
244250
// https://stackoverflow.com/questions/3674247/is-stdarrayt-s-guaranteed-to-be-pod-if-t-is-pod
245251
static_assert(std::is_pod<std::array<int, 1>>(), "");
246252
}
247-
248-
// Array of POD is POD.
249-
{
250-
struct C {};
251-
static_assert(std::is_pod<C>(), "");
252-
static_assert(std::is_pod<C[]>(), "");
253-
}
254253
}
255254

256255
// # POD effects

‎posix/interactive/setpgid.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555

5656
void signal_handler(int sig) {
5757
char sigint_str[] = "sigint\n";
58+
signal(sig, signal_handler);
5859
if (sig == SIGINT) {
59-
write(STDOUT_FILENO, sigint_str, sizeof(sigint_str));
60+
write(STDOUT_FILENO, sigint_str, sizeof(sigint_str) - 1);
6061
}
61-
signal(sig, signal_handler);
6262
}
6363

6464
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)