Back to index

glibc  2.9
Functions
setsid.c File Reference
#include <errno.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>

Go to the source code of this file.

Functions

int __setsid ()

Function Documentation

int __setsid ( void  )

Definition at line 29 of file setsid.c.

{
  pid_t pid = getpid ();
  int tty;
  int save = errno;

  if (__getpgid (pid) == pid)
    {
      /* Already the leader.  */
      __set_errno (EPERM);
      return -1;
    }

  if (setpgid (pid, pid) < 0)
    return -1;

  tty = open ("/dev/tty", 0);
  if (tty < 0)
    {
      __set_errno (save);
      return 0;
    }
  (void) __ioctl (tty, TIOCNOTTY, 0);
  (void) __close (tty);

  __set_errno (save);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: