mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/pty/pty.c (getDevice): retry once after GC on failure.
[ruby-core:08282] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
544789bd79
commit
0cd59e5b59
2 changed files with 32 additions and 20 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Jul 26 18:14:19 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/pty/pty.c (getDevice): retry once after GC on failure.
|
||||||
|
[ruby-core:08282]
|
||||||
|
|
||||||
Wed Jul 26 17:43:20 2006 Minero Aoki <aamine@loveruby.net>
|
Wed Jul 26 17:43:20 2006 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* ext/strscan/strscan.c (strscan_do_scan):
|
* ext/strscan/strscan.c (strscan_do_scan):
|
||||||
|
|
|
@ -295,37 +295,34 @@ pty_finalize_syswait(struct pty_info *info)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENPTY
|
static int
|
||||||
|
get_device_once(int *master, int *slave, int fail)
|
||||||
|
{
|
||||||
|
#if defined HAVE_OPENPTY
|
||||||
/*
|
/*
|
||||||
* Use openpty(3) of 4.3BSD Reno and later,
|
* Use openpty(3) of 4.3BSD Reno and later,
|
||||||
* or the same interface function.
|
* or the same interface function.
|
||||||
*/
|
*/
|
||||||
static void
|
|
||||||
getDevice(int *master, int *slave)
|
|
||||||
{
|
|
||||||
if (openpty(master, slave, SlaveName,
|
if (openpty(master, slave, SlaveName,
|
||||||
(struct termios *)0, (struct winsize *)0) == -1) {
|
(struct termios *)0, (struct winsize *)0) == -1) {
|
||||||
|
if (!fail) return -1;
|
||||||
rb_raise(rb_eRuntimeError, "openpty() failed");
|
rb_raise(rb_eRuntimeError, "openpty() failed");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#else /* HAVE_OPENPTY */
|
return 0;
|
||||||
#ifdef HAVE__GETPTY
|
#elif defined HAVE__GETPTY
|
||||||
static void
|
|
||||||
getDevice(int *master, int *slave)
|
|
||||||
{
|
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (!(name = _getpty(master, O_RDWR, 0622, 0))) {
|
if (!(name = _getpty(master, O_RDWR, 0622, 0))) {
|
||||||
|
if (!fail) return -1;
|
||||||
rb_raise(rb_eRuntimeError, "_getpty() failed");
|
rb_raise(rb_eRuntimeError, "_getpty() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
*slave = open(name, O_RDWR);
|
*slave = open(name, O_RDWR);
|
||||||
strcpy(SlaveName, name);
|
strcpy(SlaveName, name);
|
||||||
}
|
|
||||||
|
return 0;
|
||||||
#else /* HAVE__GETPTY */
|
#else /* HAVE__GETPTY */
|
||||||
static void
|
|
||||||
getDevice(int *master, int *slave)
|
|
||||||
{
|
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
||||||
#ifdef HAVE_PTSNAME
|
#ifdef HAVE_PTSNAME
|
||||||
|
@ -350,7 +347,7 @@ getDevice(int *master, int *slave)
|
||||||
*master = i;
|
*master = i;
|
||||||
*slave = j;
|
*slave = j;
|
||||||
strcpy(SlaveName, pn);
|
strcpy(SlaveName, pn);
|
||||||
return;
|
return 0;
|
||||||
#if defined I_PUSH && !defined linux
|
#if defined I_PUSH && !defined linux
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,7 +358,8 @@ getDevice(int *master, int *slave)
|
||||||
}
|
}
|
||||||
close(i);
|
close(i);
|
||||||
}
|
}
|
||||||
rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
|
if (!fail) rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
|
||||||
|
return -1;
|
||||||
#else
|
#else
|
||||||
char **p;
|
char **p;
|
||||||
char MasterName[DEVICELEN];
|
char MasterName[DEVICELEN];
|
||||||
|
@ -375,16 +373,25 @@ getDevice(int *master, int *slave)
|
||||||
*slave = j;
|
*slave = j;
|
||||||
chown(SlaveName, getuid(), getgid());
|
chown(SlaveName, getuid(), getgid());
|
||||||
chmod(SlaveName, 0622);
|
chmod(SlaveName, 0622);
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
close(i);
|
close(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rb_raise(rb_eRuntimeError, "can't get %s", SlaveName);
|
if (fail) rb_raise(rb_eRuntimeError, "can't get %s", SlaveName);
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif /* HAVE__GETPTY */
|
|
||||||
#endif /* HAVE_OPENPTY */
|
static void
|
||||||
|
getDevice(int *master, int *slave)
|
||||||
|
{
|
||||||
|
if (get_device_once(master, slave, 0)) {
|
||||||
|
rb_gc();
|
||||||
|
get_device_once(master, slave, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
freeDevice()
|
freeDevice()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue