No, I explicitly test this by starting a child process that does nothing but sleep, and then killing it with kill.
Code:
#ifdef SIGNALDETECTION
void child_status_change_handler(int signum)
{
puts("Signal recieved!");
signum = signum; // Eliminate unused warning
check_for_terminated_processes();
}
#endif
int main()
{
char buf[2048];
signal(SIGCHLD, &child_status_change_handler);
for (;;)
{
sighold(SIGCHLD);
printf("Ready>");
fgets(buf, sizeof(buf), stdin);
sigrelse(SIGCHLD);
const char* cmd;
const char* arg[5];
timeval begin;
sighold(SIGCHLD);
if (!get_command_and_args(buf, &cmd, arg)) goto Error;
bool failure = (!handle_command(cmd, arg, &begin));
sigrelse(SIGCHLD);
}
}
I'll start with this. This is not the complete code, but a mini-version of it to provide an overview.
I may include check_for_terminated_processes later if deemed necessary.