The following answer assumes printf()
will print immediately in stdout with no buffering like sio_printf()
as suggested in piazza.
a. there are 2 possible outputs
pikachu
kapichu
b. there are 3 possible outputs
kapichuchu
pikachuchu
pichukachu
a. There are 8 different output sequence (signal might not receive before exit(0) for children)
A possible sequence can be:
count = 1
count = 2
count = 3
b. Will be different. An example can be:
count = 1
count = 1
count = 2
count = 2
count = 3
count = 3
man sigprocmask
, gives the following:
The behavior of the call is dependent on the value of how, as follows.
SIG_BLOCK
The set of blocked signals is the union of the current set and
the set argument.
SIG_UNBLOCK
The signals in set are removed from the current set of blocked
signals. It is permissible to attempt to unblock a signal which
is not blocked.
SIG_SETMASK
The set of blocked signals is set to the argument set.
Therefore, three possible values and their corresponding behavior are:
SIG_BLOCK
: adding the set
to block mask. Therefore, everything in the set
will be blocked, and everything not in set
will remain its status.
SIG_UNBLOCK
: removing the set
from block mask. Therefore, everything in the set
will be unblocked, and everything not in set
will remain its status.
SIG_SETMASK
: everything in the set
will be blocked and everything not in the set
will be unblocked.
Table of Content