зеркало из https://github.com/github/ruby.git
Revert "hijack SIGCHLD handler for internal use"
This reverts commit 054a412d54
.
SIGCHLD `waidpid`, `waitpid_lock` and related code, have been removed
at ruby/ruby#7527.
This commit is contained in:
Родитель
cfd48adb2f
Коммит
3ac6a03b2e
|
@ -2099,7 +2099,6 @@ AC_CHECK_FUNCS(gettimeofday) # for making ac_cv_func_gettimeofday
|
||||||
AC_CHECK_FUNCS(getuid)
|
AC_CHECK_FUNCS(getuid)
|
||||||
AC_CHECK_FUNCS(getuidx)
|
AC_CHECK_FUNCS(getuidx)
|
||||||
AC_CHECK_FUNCS(gmtime_r)
|
AC_CHECK_FUNCS(gmtime_r)
|
||||||
AC_CHECK_FUNCS(grantpt)
|
|
||||||
AC_CHECK_FUNCS(initgroups)
|
AC_CHECK_FUNCS(initgroups)
|
||||||
AC_CHECK_FUNCS(ioctl)
|
AC_CHECK_FUNCS(ioctl)
|
||||||
AC_CHECK_FUNCS(isfinite)
|
AC_CHECK_FUNCS(isfinite)
|
||||||
|
|
|
@ -258,13 +258,19 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
/* Unix98 PTY */
|
/* Unix98 PTY */
|
||||||
int masterfd = -1, slavefd = -1;
|
int masterfd = -1, slavefd = -1;
|
||||||
char *slavedevice;
|
char *slavedevice;
|
||||||
|
struct sigaction dfl, old;
|
||||||
|
|
||||||
|
dfl.sa_handler = SIG_DFL;
|
||||||
|
dfl.sa_flags = 0;
|
||||||
|
sigemptyset(&dfl.sa_mask);
|
||||||
|
|
||||||
#if defined(__sun) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 902000)
|
#if defined(__sun) || defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version < 902000)
|
||||||
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
|
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
|
||||||
/* FreeBSD 9.2 or later supports O_CLOEXEC
|
/* FreeBSD 9.2 or later supports O_CLOEXEC
|
||||||
* http://www.freebsd.org/cgi/query-pr.cgi?pr=162374 */
|
* http://www.freebsd.org/cgi/query-pr.cgi?pr=162374 */
|
||||||
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
|
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
|
||||||
if (rb_grantpt(masterfd) == -1) goto error;
|
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
|
||||||
|
if (grantpt(masterfd) == -1) goto grantpt_error;
|
||||||
rb_fd_fix_cloexec(masterfd);
|
rb_fd_fix_cloexec(masterfd);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
|
@ -278,8 +284,10 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
if ((masterfd = posix_openpt(flags)) == -1) goto error;
|
if ((masterfd = posix_openpt(flags)) == -1) goto error;
|
||||||
}
|
}
|
||||||
rb_fd_fix_cloexec(masterfd);
|
rb_fd_fix_cloexec(masterfd);
|
||||||
if (rb_grantpt(masterfd) == -1) goto error;
|
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
|
||||||
|
if (grantpt(masterfd) == -1) goto grantpt_error;
|
||||||
#endif
|
#endif
|
||||||
|
if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
|
||||||
if (unlockpt(masterfd) == -1) goto error;
|
if (unlockpt(masterfd) == -1) goto error;
|
||||||
if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
|
if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
|
||||||
if (no_mesg(slavedevice, nomesg) == -1) goto error;
|
if (no_mesg(slavedevice, nomesg) == -1) goto error;
|
||||||
|
@ -297,6 +305,8 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
strlcpy(SlaveName, slavedevice, DEVICELEN);
|
strlcpy(SlaveName, slavedevice, DEVICELEN);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
grantpt_error:
|
||||||
|
sigaction(SIGCHLD, &old, NULL);
|
||||||
error:
|
error:
|
||||||
if (slavefd != -1) close(slavefd);
|
if (slavefd != -1) close(slavefd);
|
||||||
if (masterfd != -1) close(masterfd);
|
if (masterfd != -1) close(masterfd);
|
||||||
|
@ -348,17 +358,21 @@ get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg,
|
||||||
|
|
||||||
extern char *ptsname(int);
|
extern char *ptsname(int);
|
||||||
extern int unlockpt(int);
|
extern int unlockpt(int);
|
||||||
|
extern int grantpt(int);
|
||||||
|
|
||||||
#if defined(__sun)
|
#if defined(__sun)
|
||||||
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
|
/* workaround for Solaris 10: grantpt() doesn't work if FD_CLOEXEC is set. [ruby-dev:44688] */
|
||||||
if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
|
if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
|
||||||
if(rb_grantpt(masterfd) == -1) goto error;
|
s = signal(SIGCHLD, SIG_DFL);
|
||||||
|
if(grantpt(masterfd) == -1) goto error;
|
||||||
rb_fd_fix_cloexec(masterfd);
|
rb_fd_fix_cloexec(masterfd);
|
||||||
#else
|
#else
|
||||||
if((masterfd = rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
|
if((masterfd = rb_cloexec_open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
|
||||||
rb_update_max_fd(masterfd);
|
rb_update_max_fd(masterfd);
|
||||||
if(rb_grantpt(masterfd) == -1) goto error;
|
s = signal(SIGCHLD, SIG_DFL);
|
||||||
|
if(grantpt(masterfd) == -1) goto error;
|
||||||
#endif
|
#endif
|
||||||
|
signal(SIGCHLD, s);
|
||||||
if(unlockpt(masterfd) == -1) goto error;
|
if(unlockpt(masterfd) == -1) goto error;
|
||||||
if((slavedevice = ptsname(masterfd)) == NULL) goto error;
|
if((slavedevice = ptsname(masterfd)) == NULL) goto error;
|
||||||
if (no_mesg(slavedevice, nomesg) == -1) goto error;
|
if (no_mesg(slavedevice, nomesg) == -1) goto error;
|
||||||
|
|
|
@ -19,7 +19,6 @@ void (*ruby_posix_signal(int, void (*)(int)))(int);
|
||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_BEGIN
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
/* signal.c (export) */
|
/* signal.c (export) */
|
||||||
int rb_grantpt(int fd);
|
|
||||||
RUBY_SYMBOL_EXPORT_END
|
RUBY_SYMBOL_EXPORT_END
|
||||||
|
|
||||||
#endif /* INTERNAL_SIGNAL_H */
|
#endif /* INTERNAL_SIGNAL_H */
|
||||||
|
|
18
signal.c
18
signal.c
|
@ -1548,21 +1548,3 @@ Init_signal(void)
|
||||||
|
|
||||||
rb_enable_interrupt();
|
rb_enable_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_GRANTPT)
|
|
||||||
extern int grantpt(int);
|
|
||||||
#else
|
|
||||||
static int
|
|
||||||
fake_grantfd(int masterfd)
|
|
||||||
{
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#define grantpt(fd) fake_grantfd(fd)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
|
||||||
rb_grantpt(int masterfd)
|
|
||||||
{
|
|
||||||
return grantpt(masterfd);
|
|
||||||
}
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче