Skip to main content
added 722 characters in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97

what else could I improve or what problems does implementation have?

Just some minorlittle ideas:. Sorry, not much sig...() feedback.


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use const

Use const to allow call with a const char * and to better convey function's use of signame.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). It is useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string has unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block, not above

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

Error check

kill(), sigprocmask(), and other process functions deserve a check of their return values.

Error return

After perror("sigprocmask() error");, I'd expect a different return value like return EXIT_FAILURE; so calling scripts can differentiate.

Style

There are various style issues that I do not prefer like: missing {} on one-liners, void-less main(), spaced use of unary &, pointer *, 4-space indent. Yet it is more important to employ a constant style than to promote my preference. OP's code is consistent and that is good.

I do like subtle good style bits like alphabetized include.

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use const

Use const to allow call with a const char * and to better convey function's use of signame.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). It is useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string has unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

what else could I improve or what problems does implementation have?

Just some little ideas. Sorry, not much sig...() feedback.


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use const

Use const to allow call with a const char * and to better convey function's use of signame.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). It is useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string has unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block, not above

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

Error check

kill(), sigprocmask(), and other process functions deserve a check of their return values.

Error return

After perror("sigprocmask() error");, I'd expect a different return value like return EXIT_FAILURE; so calling scripts can differentiate.

Style

There are various style issues that I do not prefer like: missing {} on one-liners, void-less main(), spaced use of unary &, pointer *, 4-space indent. Yet it is more important to employ a constant style than to promote my preference. OP's code is consistent and that is good.

I do like subtle good style bits like alphabetized include.

added 2 characters in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use const

Use const to allow call with a const char * to allow call with a and to better convey function'sconst usechar of*gigname` and to better convey function's use of signame.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). Its It is useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string havehas unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use const

Use const to allow call with a const char *and to better convey function's use ofgigname`.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). Its useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string have unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use const

Use const to allow call with a const char * and to better convey function's use of signame.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). It is useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string has unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);
added 55 characters in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some code comments in the .c file to indicate overall functionality.

Use  const

Use const to allow call with a const char *and to better convey function's use ofgigname`.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). Its useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string have unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some code comments to indicate overall functionality.

Use const

Use const to allow call with a const char *and to better convey function's use ofgigname`.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). Its useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);

what else could I improve or what problems does implementation have?

Just some minor ideas:


Lack of documentation

At least some comments in the .c file to indicate overall functionality.

Use  const

Use const to allow call with a const char *and to better convey function's use ofgigname`.

// void check_pending(int signum, char * signame)
void check_pending(int signum, const char * signame)

Clearer message

Consider a sentence and not lower case.

Example below, but applies to other output as well.

// printf("a %s signal is pending\n", signame);
printf("A %s signal is pending.\n", signame);

From time-to-time and especially in error messages, it is really nice to see a string printed with sentinels (like quote-marks). Its useful in seeing what part of output is format and what is data.

printf("A \"%s\" signal is pending.\n", signame);

In error message this in even more important as something went wrong. Maybe the string have unexpected leading/trailing white-space that is messing up the operation?

Fully initialize

Consider these 2 code snippets. The 2nd one fully initializes sigact- even members that are not obviously important.

// OP
struct sigaction sigact;
sigemptyset( & sigact.sa_mask);
sigact.sa_flags = 0;
sigact.sa_handler = catcher;

// Suggested
// This initializes all members, not just .sa_flags, .sa_handler.
struct sigaction sigact = { .sa_flags = 0, .sa_handler = catcher };
sigemptyset( & sigact.sa_mask);

Define in needed block

// sigset_t sigset;
...
else {
    sigset_t sigset;
    sigemptyset( & sigset);
added 55 characters in body
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97
Loading
Source Link
chux
  • 36.5k
  • 2
  • 43
  • 97
Loading