#include <sys/types.h> #include <unistd.h> pid_t setsid(void);
setsidcreates a new session. The calling process is its session leader. The calling process is the process group leader of the new process group; it must not already be a process group leader. The calling process does not have a controlling terminal. The calling process begins as the only process in the new process group and in the new session. The process group ID of the new process group is equal to the process ID of the caller.
setsidreturns the value of the new process group ID of the calling process.
-1if not successful.
setsidto create a new session:
#include <sys/types.h> #include <unistd.h> #include <stdio.h> pid_t pid; . . . printf("The process group ID is %d\n", (int) getpgrp()); if ((pid = setsid()) == -1) perror("setsid error"); else printf("The new process group ID is %d\n", (int) pid); . . .
Also see the
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.