Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* parent */
- #include <stdio.h>
- #include <signal.h>
- #include <unistd.h>
- #include <sys/types.h>
- int flag;
- void sigusr1_handler( int sig )
- {
- printf( "caught sigusr1! terminating!\n" );
- flag = 0;
- }
- int main()
- {
- flag = 1;
- signal( SIGUSR1, sigusr1_handler );
- if( fork() == 0 ) execve( "./bin2", NULL, NULL );
- while( flag );
- }
- /* child */
- #include <stdio.h>
- #include <signal.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <errno.h>
- #include <assert.h>
- void sigusr1_handler( int sig )
- {
- printf( "sending signal to parent return: %d\n", kill( getppid(), SIGUSR1 ) );
- exit( 0 );
- }
- int main( int argc, char **argv )
- {
- errno = 0;
- signal( SIGUSR1, sigusr1_handler );
- assert( errno == 0 );
- while( 1 );
- }
Advertisement
Add Comment
Please, Sign In to add comment