summaryrefslogtreecommitdiff
path: root/ext/pty/pty.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-10 01:29:58 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-10 01:29:58 +0000
commit18088467e7489eff252eeb5b904bc93c2949462f (patch)
tree84276ef8a48616ad2613f8e6d2ea00bc716b5339 /ext/pty/pty.c
parent5bd7899b98fc4fd9631d08423f5c2fb6918c783d (diff)
* process.c (rb_exec_async_signal_safe): exported.
* ext/pty/extconf.rb: modify $INCFLAGS to include internal.h * ext/pty/pty.c: include internal.h. (chfunc): don't call rb_thread_atfork_before_exec. use rb_exec_async_signal_safe instead of rb_f_exec. (establishShell): set up earg. use rb_fork_async_signal_safe instead of rb_fork_err. * internal.h (rb_exec_async_signal_safe): declared. (rb_fork_async_signal_safe): declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pty/pty.c')
-rw-r--r--ext/pty/pty.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index ee56d58..bdb52d4 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -32,6 +32,7 @@
#include "ruby/ruby.h"
#include "ruby/io.h"
#include "ruby/util.h"
+#include "internal.h"
#include <signal.h>
#ifdef HAVE_SYS_STROPTS_H
@@ -77,8 +78,7 @@ static void getDevice(int*, int*, char [DEVICELEN], int);
struct child_info {
int master, slave;
char *slavename;
- int argc;
- VALUE *argv;
+ struct rb_exec_arg earg;
};
static int
@@ -87,16 +87,12 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
struct child_info *carg = data;
int master = carg->master;
int slave = carg->slave;
- int argc = carg->argc;
- VALUE *argv = carg->argv;
#define ERROR_EXIT(str) do { \
strlcpy(errbuf, (str), errbuf_len); \
return -1; \
} while (0)
- rb_thread_atfork_before_exec();
-
/*
* Set free from process group and controlling terminal
*/
@@ -146,8 +142,7 @@ chfunc(void *data, char *errbuf, size_t errbuf_len)
seteuid(getuid());
#endif
- rb_f_exec(argc, argv);
- return 0;
+ return rb_exec_async_signal_safe(&carg->earg, errbuf, sizeof(errbuf_len));
#undef ERROR_EXIT
}
@@ -181,15 +176,16 @@ establishShell(int argc, VALUE *argv, struct pty_info *info,
argv = &v;
}
+ rb_exec_arg_init(argc, argv, 1, &carg.earg);
+ rb_exec_arg_fixup(&carg.earg);
+
getDevice(&master, &slave, SlaveName, 0);
carg.master = master;
carg.slave = slave;
carg.slavename = SlaveName;
- carg.argc = argc;
- carg.argv = argv;
errbuf[0] = '\0';
- pid = rb_fork_err(&status, chfunc, &carg, Qnil, errbuf, sizeof(errbuf));
+ pid = rb_fork_async_signal_safe(&status, chfunc, &carg, Qnil, errbuf, sizeof(errbuf));
if (pid < 0) {
int e = errno;