| Module | PTY |
| In: |
pty/pty.c
|
ruby function: getpty
/* ruby function: getpty */
static VALUE
pty_getpty(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
{
VALUE res;
struct pty_info info;
struct pty_info thinfo;
OpenFile *wfptr,*rfptr;
VALUE rport = rb_obj_alloc(rb_cFile);
VALUE wport = rb_obj_alloc(rb_cFile);
MakeOpenFile(rport, rfptr);
MakeOpenFile(wport, wfptr);
establishShell(argc, argv, &info);
rfptr->mode = rb_io_mode_flags("r");
rfptr->f = fdopen(info.fd, "r");
rfptr->path = strdup(SlaveName);
wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC;
wfptr->f = fdopen(dup(info.fd), "w");
wfptr->path = strdup(SlaveName);
res = rb_ary_new2(3);
rb_ary_store(res,0,(VALUE)rport);
rb_ary_store(res,1,(VALUE)wport);
rb_ary_store(res,2,INT2FIX(info.child_pid));
thinfo.thread = rb_thread_create(pty_syswait, (void*)&info);
thinfo.child_pid = info.child_pid;
rb_thread_schedule();
if (rb_block_given_p()) {
rb_ensure(rb_yield, res, pty_finalize_syswait, (VALUE)&thinfo);
return Qnil;
}
return res;
}
ruby function: protect_signal - obsolete
/* ruby function: protect_signal - obsolete */
static VALUE
pty_protect(self)
VALUE self;
{
rb_warn("PTY::protect_signal is no longer needed");
rb_yield(Qnil);
return self;
}
ruby function: reset_signal - obsolete
/* ruby function: reset_signal - obsolete */
static VALUE
pty_reset_signal(self)
VALUE self;
{
rb_warn("PTY::reset_signal is no longer needed");
return self;
}
ruby function: getpty
/* ruby function: getpty */
static VALUE
pty_getpty(argc, argv, self)
int argc;
VALUE *argv;
VALUE self;
{
VALUE res;
struct pty_info info;
struct pty_info thinfo;
OpenFile *wfptr,*rfptr;
VALUE rport = rb_obj_alloc(rb_cFile);
VALUE wport = rb_obj_alloc(rb_cFile);
MakeOpenFile(rport, rfptr);
MakeOpenFile(wport, wfptr);
establishShell(argc, argv, &info);
rfptr->mode = rb_io_mode_flags("r");
rfptr->f = fdopen(info.fd, "r");
rfptr->path = strdup(SlaveName);
wfptr->mode = rb_io_mode_flags("w") | FMODE_SYNC;
wfptr->f = fdopen(dup(info.fd), "w");
wfptr->path = strdup(SlaveName);
res = rb_ary_new2(3);
rb_ary_store(res,0,(VALUE)rport);
rb_ary_store(res,1,(VALUE)wport);
rb_ary_store(res,2,INT2FIX(info.child_pid));
thinfo.thread = rb_thread_create(pty_syswait, (void*)&info);
thinfo.child_pid = info.child_pid;
rb_thread_schedule();
if (rb_block_given_p()) {
rb_ensure(rb_yield, res, pty_finalize_syswait, (VALUE)&thinfo);
return Qnil;
}
return res;
}