Back to index

glibc  2.9
forkpty.c File Reference
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <utmp.h>
#include <pty.h>

Go to the source code of this file.


int forkpty (int *amaster, char *name, const struct termios *termp, const struct winsize *winp)

Function Documentation

int forkpty ( int amaster,
char *  name,
const struct termios termp,
const struct winsize winp 

Definition at line 27 of file forkpty.c.

  int master, slave, pid;

  if (openpty (&master, &slave, name, termp, winp) == -1)
    return -1;

  switch (pid = fork ())
    case -1:
      close (master);
      close (slave);
      return -1;
    case 0:
      /* Child.  */
      close (master);
      if (login_tty (slave))
       _exit (1);

      return 0;
      /* Parent.  */
      *amaster = master;
      close (slave);

      return pid;

Here is the call graph for this function: