#include #include #include #include #include extern char **environ; pid_t run_sleep () { pid_t pid; char *argv[] = { "sleep", "3600", NULL }; int err = posix_spawnp (&pid, "/usr/bin/sleep", NULL, NULL, argv, environ); if (err == 0) return pid; else { printf ("posix_spawnp: %s\n", strerror (err)); exit (1); } } int main () { pid_t pid = run_sleep (); kill (pid, SIGTERM); }