I am currently busy with multiprocessing and multithreading. There I saw a signal SIGCHLD which is an excellent zombie process cleaner by handling that signal.

But when we are writing our handler function why we declaring it with an signal number arguement ? Is this arguement is automatically passed by sigaction() function ? Here below is the code

void ZombieHandler(int signal_num) // why is signal_num needed? Is it passed implicitly by sigaction() function ?
	int status;
	wait(&status);	// clean up the ended process and save the status
	child_exit_status = status;
int main(int argc, char** args)
	struct sigaction sigchild_action;
	memset(&sigchild_action, 0, sizeof sigchild_action);
	sigchild_action.sa_handler = &ZombieHandler;
	sigaction(SIGCHLD, &sa, NULL);

	/*Do things, create child processes
	// and they will be handled securely*/
	return 0;


The argument is passed by the OS when the signal is delivered. The rationale is that you may install the same handler for different signals.

This question has already been answered. Start a new discussion instead.