Hello everyone,
Suppose process A forks/execs process B, and immediately sends a signal
to process B.
int child_pid = fork();
if (child_pid == 0) // child
execv("/bin/progB", argv);
// parent
kill(child_pid, 64);
Assume the first thing progB does is to install a handler for signal 64.
It seems to me that there is a race:
If process B runs first after the fork, then all is well, B installs the handler,
then process A sends the signal, and everyone lives happily ever after.
However, if process A runs first after the fork, the OS delivers the signal before process B enters main(), perhaps even before it execs. Process B then terminates in agony.
Does this fall under the "don't do that!" rule?
Or perhaps program A is expected to set the signal mask for
progB before even calling fork()?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 24:15:09 |
Calls: | 6,646 |
Calls today: | 1 |
Files: | 12,193 |
Messages: | 5,327,714 |