8 /* When a @code{SIGUSR1} signal arrives, set this variable. */
9 volatile sig_atomic_t usr_interrupt
= 0;
12 synch_signal (int sig
)
17 /* The child process executes this function. */
21 /* Perform initialization. */
22 printf ("I'm here!!! My pid is %d.\n", (int) getpid ());
24 /* Let parent know you're done. */
25 kill (getppid (), SIGUSR1
);
27 /* Continue with execution. */
28 puts ("Bye, now....");
35 struct sigaction usr_action
;
39 /* Establish the signal handler. */
40 sigfillset (&block_mask
);
41 usr_action
.sa_handler
= synch_signal
;
42 usr_action
.sa_mask
= block_mask
;
43 usr_action
.sa_flags
= 0;
44 sigaction (SIGUSR1
, &usr_action
, NULL
);
46 /* Create the child process. */
49 child_function (); /* Does not return. */
52 /* Busy wait for the child to send a signal. */
53 while (!usr_interrupt
)
57 /* Now continue execution. */
58 puts ("That's all, folks!");