lkml.org 
[lkml]   [1997]   [Oct]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectshutdown hangs
Hello,

on every maching I upgraded to linux 2.0.x (elf) (1.2.13 aout before),
shutdown stopped to work reliably. It seems, shortly after sending all other
processes the kill signal, somehow the tty output hangs.

Yes, I know that the Changes file says that I should upgrade to a newer
sysvinit package (I am still running 2.4), but even upgrading to 2.71
did N O T solve the problem, it only changed some of the symptoms.

Since the shutdown procedure from sysvinit 2.4 seems less complicated
to me (compared to the newer ones), I think this would be a good
starting point for an analysis of the problem. Here is an excerpt of
the corresponding parts of halt.c:

printf("\r%s: sending all processes the TERM signal", "halt");
kill(-1, SIGTERM);
dotdot(sltime); /* outputs ........... (one '.' every second) */
-> printf("%s: sending all processes the KILL signal..\r\n", "halt");

kill(-1, SIGKILL);
sync();
if ((fd = open(WTMP, O_WRONLY|O_APPEND)) >= 0) {
time(&t);
strcpy(wtmp.ut_user, "shutdown");
strcpy(wtmp.ut_line, "~");
strcpy(wtmp.ut_id, "~~");
wtmp.ut_pid = 0;
wtmp.ut_type = RUN_LVL;
wtmp.ut_time = t;
write(fd, (char *)&wtmp, sizeof(wtmp));
close(fd);
}

/* Now we're alone, execute /etc/brc */
if ((pid = fork()) == 0) {
execlp(DOWN1, DOWN1, (char *)NULL); /*fails, DOWN1 not existent*/
execlp("/etc/brc", "brc", (char *)NULL); /*existes,
exit(1); /*never reached therefore*/
}
if (pid > 0)
wait(&st);
sync();
printf("\r\nThe system is halted\r\n");
exit(0);

/etc/brc looks something like:
#!/bin/sh
echo Unmounting all file systems
umount -a
echo done

The problems start during or after the marked printf:

1) if shutdown is executed directly from a login shell script, and if we have
a fast processor (i.e. pentium) everything is working. (on an older 386, the
computer hangs during the execution of /etc/brc, especially, if this script
is longer (more output to stdout) then the one above)

2) login as root on the vga console and executing "shutdown now -t 5 -h":
The program completes, all filesystems are unmounted, but I don't get
the corresponding messages; the output stops after the marked printf.
I am absolutely sure, that /etc/brc got executed, since the filesystems
are marked clean at the next boot. There are also no processes left in
the process table beside swapper, init, kswapd and kflushd.

3) login as root on a serial line (19200 baud, rather slow terminal,
RTS/CTS handshaking):
Again, all gets executed, but this time the output stops in the middle
of the printf statement, I only get "halt", everything from (including)
": sending all processes the KILL signal..\r\n" on is missing.

Since the processes itself finish successfully, I suspect that the messages
are output to the linux internal tty buffers, but somehow the linux tty code
stops outputing them. This would be consistent with the fact, that with larger
messages from /etc/brc, i.e. if the linux internal buffer is full, /etc/brc
completely hangs on slow systems (some additional /bin/sh processes are
visible then via <ctrl><scroll lock>, which never finish, if I remember
that correctly)

Any ideas? The same setup works perfectly even on the slowest 386 under
linux 1.2.13. Everything beside the linux kernel (and the modules package)
is (still) the same, so some changes in the kernel code between 1.2.13 and
2.0.29 must at least trigger that problem.

Please also tell me what exactly the race conditions are, that you tried
to fix in the newer releases of sysvinit; I could not find any hints in
the package/source code-

Thank you very mouch for your help
--
Bernd Anhaeupl Tel.: +49 9131 857787
LATE - Uni Erlangen
Cauerstr. 7 Email: anhaeupl@late.e-technik.uni-erlangen.de
91058 Erlangen

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