c - How to make two processes signalling each others continuously? -
i want simulate game server should continuously send , receive signals parent. scenario follows: parent sends signal game. game catches signal , sends signal parent. parent catches signal , sends again signal game. and on... the problem stops receiving or sending after first lap: static int game_s; void game() { printf("game\n"); signal(sigusr1,game); sleep(1); kill(getppid(),sigusr1); pause(); } void parent() { printf("parent\n"); signal(sigusr1,parent); sleep(1); kill(game_s,sigusr1); pause(); } void main() { game_s = fork(); if(game_s>0) { signal(sigusr1,parent); sleep(1); kill(game_s,sigusr1); pause(); } else { signal(sigusr1,game); pause(); } } the output following: game parent why stopped here? shouldn't game server catch parent's signal , print "game" again... by default reception of