summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_init.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2002-05-24 04:32:28 +0000
committerdeischen <deischen@FreeBSD.org>2002-05-24 04:32:28 +0000
commit9ba1f9fa381dcbfb861533fdda13f9f27da78f14 (patch)
tree15691e04d3960954bb9843fcfd9d5beaf2553f80 /lib/libpthread/thread/thr_init.c
parentabd4f3d6cc97e6f9042d207b7f1442f11860e88d (diff)
downloadFreeBSD-src-9ba1f9fa381dcbfb861533fdda13f9f27da78f14.zip
FreeBSD-src-9ba1f9fa381dcbfb861533fdda13f9f27da78f14.tar.gz
Revamp suspend and resume. While I'm here add pthread_suspend_all_np()
and pthread_resume_all_np(). These suspend and resume all threads except the current thread, respectively. The existing functions pthread_single_np() and pthread_multi_np(), which formerly had no effect, now exhibit the same behaviour and pthread_suspend_all_np() and pthread_resume_all_np(). These functions have been added mostly for the native java port. Don't allow the uthread kernel pipe to use the same descriptors as stdio. Mostily submitted by Oswald Buddenhagen <ossi@kde.org>. Correct some minor style nits.
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r--lib/libpthread/thread/thr_init.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c
index 2790748..74db740 100644
--- a/lib/libpthread/thread/thr_init.c
+++ b/lib/libpthread/thread/thr_init.c
@@ -201,20 +201,21 @@ _thread_init(void)
PANIC("Can't open console");
if (setlogin("root") == -1)
PANIC("Can't set login to root");
- if (__sys_ioctl(fd,TIOCSCTTY, (char *) NULL) == -1)
+ if (__sys_ioctl(fd, TIOCSCTTY, (char *) NULL) == -1)
PANIC("Can't set controlling terminal");
- if (__sys_dup2(fd,0) == -1 ||
- __sys_dup2(fd,1) == -1 ||
- __sys_dup2(fd,2) == -1)
+ if (__sys_dup2(fd, 0) == -1 ||
+ __sys_dup2(fd, 1) == -1 ||
+ __sys_dup2(fd, 2) == -1)
PANIC("Can't dup2");
}
/* Get the standard I/O flags before messing with them : */
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++) {
if (((_pthread_stdio_flags[i] =
- __sys_fcntl(i,F_GETFL, NULL)) == -1) &&
+ __sys_fcntl(i, F_GETFL, NULL)) == -1) &&
(errno != EBADF))
PANIC("Cannot get stdio flags");
+ }
/*
* Create a pipe that is written to by the signal handler to prevent
@@ -224,8 +225,21 @@ _thread_init(void)
/* Cannot create pipe, so abort: */
PANIC("Cannot create kernel pipe");
}
+
+ /*
+ * Make sure the pipe does not get in the way of stdio:
+ */
+ for (i = 0; i < 2; i++) {
+ if (_thread_kern_pipe[i] < 3) {
+ fd = __sys_fcntl(_thread_kern_pipe[i], F_DUPFD, 3);
+ if (fd == -1)
+ PANIC("Cannot create kernel pipe");
+ __sys_close(_thread_kern_pipe[i]);
+ _thread_kern_pipe[i] = fd;
+ }
+ }
/* Get the flags for the read pipe: */
- else if ((flags = __sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) {
+ if ((flags = __sys_fcntl(_thread_kern_pipe[0], F_GETFL, NULL)) == -1) {
/* Abort this application: */
PANIC("Cannot get kernel read pipe flags");
}
OpenPOWER on IntegriCloud