diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-18 21:14:42 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-18 21:14:42 +0000 |
commit | 085d68bcc29ecddb6c48e9f32c20648db28f4417 (patch) | |
tree | 38df8886a1a5fa2a5b0f3cebf0a773ecc9b2f221 /compat | |
parent | 9b0ff4cfc02d5fb5be03d66aba9720971bbf55e2 (diff) |
Solaris bits.
Diffstat (limited to 'compat')
-rw-r--r-- | compat/forkpty-sunos.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/compat/forkpty-sunos.c b/compat/forkpty-sunos.c index 27a44bc2..e333b80e 100644 --- a/compat/forkpty-sunos.c +++ b/compat/forkpty-sunos.c @@ -1,4 +1,4 @@ -/* $Id: forkpty-sunos.c,v 1.2 2008-06-18 20:11:25 nicm Exp $ */ +/* $Id: forkpty-sunos.c,v 1.3 2008-06-18 21:14:42 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -45,19 +45,29 @@ forkpty(int *master, if ((slave = open(path, O_RDWR)) == -1) goto out; - if (ioctl(slave, I_PUSH, "ptem") == -1) - fatal("ioctl failed"); - if (ioctl(slave, I_PUSH, "ldterm") == -1) - fatal("ioctl failed"); - - if (ioctl(slave, TIOCSWINSZ, ws) == -1) - fatal("ioctl failed"); - switch (pid = fork()) { case -1: goto out; case 0: close(*master); + + setsid(); + if (ioctl(slave, TIOCSCTTY, NULL) == -1) + fatal("ioctl failed"); + + if (ioctl(slave, I_PUSH, "ptem") == -1) + fatal("ioctl failed"); + if (ioctl(slave, I_PUSH, "ldterm") == -1) + fatal("ioctl failed"); + + if (ioctl(slave, TIOCSWINSZ, ws) == -1) + fatal("ioctl failed"); + + dup2(slave, 0); + dup2(slave, 1); + dup2(slave, 2); + if (slave > 2) + close(slave); return (0); } |