Exercise 3/Source code/proc-common.c
/*
 * Print the process tree rooted at process with PID p.
 */
Print the process tree rooted at process with PID p.
Print the process tree rooted at process with PID p .
void
show_pstree(pid_t p)
{
	int ret;
	char cmd[1024];
	snprintf(cmd, sizeof(cmd), "echo; echo; pstree -G -c -p %ld; echo; echo",
		(long)p);
	cmd[sizeof(cmd)-1] = '\0';
	ret = system(cmd);
	if (ret < 0) {
		perror("system");
		exit(104);
	}
}
void show_pstree ( pid_t p ) { int ret ; char cmd [ 1024 ] ; snprintf ( cmd , sizeof ( cmd ) , " " , ( long ) p ) ; cmd [ sizeof ( cmd ) - 1 ] = ' \0 ' ; ret = system ( cmd ) ; if ( ret < 0 ) { perror ( " " ) ; exit ( 104 ) ; } }
Print the process tree rooted at process with PID p.
Print the process tree rooted at process with PID p .