From b1ad30b2f72b0802ddfb363ff3b4477d9a3c1e15 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 16 Sep 2006 07:21:02 +0000 Subject: [PATCH] * ext/pty/pty.c (establishShell): parent pid is not used. * ext/pty/pty.c (freeDevice): not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++++- ext/pty/pty.c | 32 +++++++++++++------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2318a5d34b..e2751eb621 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -Sat Sep 16 16:14:40 2006 Nobuyoshi Nakada +Mon Jan 16 16:20:35 2006 Nobuyoshi Nakada * Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb: use instruby.rb to install extensions instead of ext/extmk.rb. @@ -9,6 +9,10 @@ Sat Sep 16 16:14:40 2006 Nobuyoshi Nakada * ext/io/wait/extconf.rb: suspicious checking_for. + * ext/pty/pty.c (establishShell): parent pid is not used. + + * ext/pty/pty.c (freeDevice): not used. + Sat Sep 16 11:03:49 2006 Yukihiro Matsumoto * array.c (ary_shared_first): should create embedded copies diff --git a/ext/pty/pty.c b/ext/pty/pty.c index ae5ee0b68a..215f2cfd6d 100644 --- a/ext/pty/pty.c +++ b/ext/pty/pty.c @@ -1,4 +1,7 @@ #include "config.h" +#ifdef RUBY_EXTCONF_H +#include RUBY_EXTCONF_H +#endif #include #include #include @@ -62,7 +65,7 @@ char *MasterDevice = "/dev/ptym/pty%s", 0, }; #elif defined(_IBMESA) /* AIX/ESA */ -static +static char *MasterDevice = "/dev/ptyp%s", *SlaveDevice = "/dev/ttyp%s", *deviceNo[] = { @@ -84,7 +87,7 @@ char *MasterDevice = "/dev/ptyp%s", "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff", }; #elif !defined(HAVE_PTSNAME) -static +static char *MasterDevice = "/dev/pty%s", *SlaveDevice = "/dev/tty%s", *deviceNo[] = { @@ -136,7 +139,7 @@ raise_from_wait(char *state, struct pty_info *info) char buf[1024]; VALUE exc; - snprintf(buf, sizeof(buf), "pty - %s: %d", state, info->child_pid); + snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid); exc = rb_exc_new2(eChildExited, buf); rb_iv_set(exc, "status", rb_last_status); rb_funcall(info->thread, rb_intern("raise"), 1, exc); @@ -172,7 +175,7 @@ pty_syswait(struct pty_info *info) } } -static void getDevice _((int*, int*)); +static void getDevice(int*, int*); struct exec_info { int argc; @@ -180,15 +183,16 @@ struct exec_info { }; static VALUE -pty_exec(struct exec_info *arg) +pty_exec(VALUE v) { + struct exec_info *arg = (struct exec_info *)v; return rb_f_exec(arg->argc, arg->argv); } static void establishShell(int argc, VALUE *argv, struct pty_info *info) -{ - static int i,master,slave,currentPid; +{ + int i,master,slave; char *p,*getenv(); struct passwd *pwent; VALUE v; @@ -215,7 +219,6 @@ establishShell(int argc, VALUE *argv, struct pty_info *info) getDevice(&master,&slave); info->thread = rb_thread_current(); - currentPid = getpid(); if((i = fork()) < 0) { close(master); close(slave); @@ -223,8 +226,6 @@ establishShell(int argc, VALUE *argv, struct pty_info *info) } if(i == 0) { /* child */ - currentPid = getpid(); - /* * Set free from process group and controlling terminal */ @@ -236,7 +237,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info) if (setpgrp() == -1) perror("setpgrp()"); # else /* SETGRP_VOID */ - if (setpgrp(0, currentPid) == -1) + if (setpgrp(0, getpid()) == -1) rb_sys_fail("setpgrp()"); if ((i = open("/dev/tty", O_RDONLY)) < 0) rb_sys_fail("/dev/tty"); @@ -393,13 +394,6 @@ getDevice(int *master, int *slave) } } -static void -freeDevice() -{ - chmod(SlaveName, 0666); - chown(SlaveName, 0, 0); -} - /* ruby function: getpty */ static VALUE pty_getpty(int argc, VALUE *argv, VALUE self) @@ -410,7 +404,7 @@ pty_getpty(int argc, VALUE *argv, VALUE self) OpenFile *wfptr,*rfptr; VALUE rport = rb_obj_alloc(rb_cFile); VALUE wport = rb_obj_alloc(rb_cFile); - + MakeOpenFile(rport, rfptr); MakeOpenFile(wport, wfptr);