lkml.org 
[lkml]   [1996]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: Linux-1.3.81& sysvinit
Date
You (Karl Keyte) wrote:
> I fixed sysvinit-2.59 to work with 1.3.81 and dumped the changes in
> sunsite's incoming. It's running fine for me and allows runlevel
> changes.

As Linus pointed out to me, simply opening the pipe O_RDWR instead of
O_RDONLY is enough. The above mentioned patch is subject to nasty
race conditions.

Here a proper patch, that also fixes another race condition.

NOTE: This is NOT the official 2.60.

--- sysvinit-2.59/init.c Sun Mar 10 11:37:29 1996
+++ sysvinit-2.60/init.c Tue Apr 2 13:44:50 1996
@@ -242,6 +242,10 @@
sigaddset(&got_signals, SIGCHLD);
ch->exstat = st;
ch->flags |= ZOMBIE;
+ if (ch->new) {
+ ch->new->exstat = st;
+ ch->new->flags |= ZOMBIE;
+ }
break;
}
#if DEBUG
@@ -1411,7 +1415,7 @@

/* Try to open /dev/initctl */
if (pipe_fd < 0) {
- if ((pipe_fd = open(INIT_FIFO, O_RDONLY|O_NONBLOCK)) >= 0) {
+ if ((pipe_fd = open(INIT_FIFO, O_RDWR|O_NONBLOCK)) >= 0) {
/* Don't use fd's 0, 1 or 2. */
(void) dup2(pipe_fd, PIPE_FD);
close(pipe_fd);
@@ -1433,6 +1437,16 @@

/* Read the data, return on EINTR. */
n = read(pipe_fd, &request, sizeof(request));
+ if (n == 0) {
+ /*
+ * End of file. This can't happen under Linux (because
+ * the pipe is opened O_RDWR - see select() in the
+ * kernel) but you never know...
+ */
+ close(pipe_fd);
+ pipe_fd = -1;
+ return;
+ }
if (n <= 0) {
if (errno == EINTR) return;
Log(L_VB, "error reading initrequest");
--
Miquel van | Cistron Internet Services -- Alphen aan den Rijn.
Smoorenburg, | mailto:info@cistron.nl http://www.cistron.nl/
miquels@het.net | Tel: +31-172-419445 (Voice) 430979 (Fax) 442580 (Data)

\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.027 / U:0.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site