summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-13 09:42:40 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-13 09:42:40 +0000
commit9ee0cafbfe7a94a7b6a9d0e7f2dbf7c7fd229757 (patch)
tree6bf09f98a1fdc4f538a37d9d12b7ce602c63b0a6 /process.c
parent97f8593cf8af3b44e170fee5aca9b0a521cd3ffd (diff)
2000-06-13
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/process.c b/process.c
index bd078a3c8d..8077de5495 100644
--- a/process.c
+++ b/process.c
@@ -826,13 +826,29 @@ proc_setpgid(obj, pid, pgrp)
static VALUE
proc_setsid()
{
-#ifdef HAVE_SETSID
+#if defined(HAVE_SETSID)
int pid;
rb_secure(2);
pid = setsid();
if (pid < 0) rb_sys_fail(0);
return INT2FIX(pid);
+#elif defined(HAVE_SETPGRP) && defined(TIOCNOTTY)
+ pid_t sid;
+
+#if defined(SETPGRP_VOID)
+ sid = setpgrp();
+#else
+ sid = setpgrp(0, getpid());
+#endif
+ if (sid == -1) return -1;
+
+ if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
+ ioctl(fd, TIOCNOTTY, NULL);
+ close(fd);
+ }
+ return sid;
+}
#else
rb_notimplement();
#endif
@@ -1025,9 +1041,7 @@ Init_process()
#endif
#endif
-#if !defined(NT)
rb_define_singleton_method(rb_mProcess, "fork", rb_f_fork, 0);
-#endif
rb_define_singleton_method(rb_mProcess, "exit!", rb_f_exit_bang, -1);
rb_define_module_function(rb_mProcess, "kill", rb_f_kill, -1);
#ifndef NT