[PATCH] init.c, halt command not working
Denys Vlasenko
vda.linux at googlemail.com
Wed Apr 2 14:41:44 PDT 2008
On Wednesday 02 April 2008 22:50, Harald Kuethe wrote:
> > ----- Original Message -----
> > From: "Denys Vlasenko" <vda.linux at googlemail.com>
> > To: "Harald Kuethe" <harald-tuxbox at arcor.de>
> > Cc: <busybox at busybox.net>
> > Sent: Tuesday, April 01, 2008 11:51 PM
> > Subject: Re: [PATCH] init.c, halt command not working
>
>
> > On Tuesday 01 April 2008 23:41, Harald Kuethe wrote:
> > > > ----- Original Message -----
> > > > From: "Denys Vlasenko" <vda.linux at googlemail.com>
> > > > To: <busybox at busybox.net>
> > > > Cc: "Harald Küthe" <harald-tuxbox at arcor.de>
> > > > Sent: Monday, March 31, 2008 9:52 PM
> > > > Subject: Re: [PATCH] init.c, halt command not working
> > >
> > >
> > > > On Monday 31 March 2008 21:59, Harald Küthe wrote:
> > > > > > The sequence of events is:
> > > > > > SIGUSR1 is received
> > > > > > halt_reboot_pwoff(SIGUSR1) calls
> > > > > > kill_all_processes() calls
> > > > > > run_actions(SHUTDOWN):
> > > > > > if (a->action_type & (SYSINIT | WAIT |
> > > > > CTRLALTDEL | SHUTDOWN | RESTART)) {
> > > > > > waitfor(run(a));
> > > > > > delete_init_action(a);
> > > > > > run(a) vforks... and this is somehow doesn't work very well
> > > > >
> > > > > It looks as if SIGUSR1 is !!not!! received because halt_reboot_pwoff()
> > > > > is not processed.
> >
> > > > Please confirm that you added a debug printout to
> > > > halt_reboot_pwoff and it is not triggering when halt
> > > > sends SIGUSR1 to init.
> > >
> > > Yes, confirmed!
> >
> > And also it doesn't trigger when you send signal by hand -
> > "kill -USR1 1" ?
>
> Yes no trigger with this
>
> > --
> > vda
>
> I attached a strace output of the killall init (which restarts the system) as well as of the kill 1 (which does not)
> Maybe this helps.
>
> / # strace -fF killall init
> execve("/bin/killall", ["killall", "init"], [/* 7 vars */]) = 0
> brk(0) = 0x10068a24
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x30017000
> ...
> mprotect(0xffc7000, 4096, PROT_READ) = 0
> mprotect(0x30026000, 4096, PROT_READ) = 0
> getuid() = 0
> getpid() = 91
> brk(0) = 0x10068a24
> brk(0x10089a24) = 0x10089a24
> brk(0x1008a000) = 0x1008a000
> open("/dev/null", O_RDONLY|O_NONBLOCK|O_DIRECTORY) = -1 ENOTDIR (Not a directory)
> open("/proc", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 3
> fstat64(3, {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
> fcntl64(3, F_SETFD, FD_CLOEXEC) = 0
> getdents64(3, /* 35 entries */, 1024) = 1024
> getdents64(3, /* 17 entries */, 1024) = 408
> open("/proc/1/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "1 (init) D 0 0 0 0 -1 256 12 236"..., 1023) = 183
> close(4) = 0
> open("/proc/2/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "2 (keventd) S 1 1 1 0 -1 64 0 0 "..., 1023) = 121
> close(4) = 0
> open("/proc/3/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "3 (ksoftirqd_CPU0) S 1 1 1 0 -1 "..., 1023) = 126
> close(4) = 0
> open("/proc/4/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "4 (kswapd) S 1 1 1 0 -1 2112 0 0"..., 1023) = 118
> close(4) = 0
> open("/proc/5/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "5 (bdflush) S 1 1 1 0 -1 64 0 0 "..., 1023) = 117
> close(4) = 0
> open("/proc/6/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "6 (kupdated) S 1 1 1 0 -1 64 0 0"..., 1023) = 118
> close(4) = 0
> open("/proc/7/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "7 (cifsoplockd) S 1 1 1 0 -1 64 "..., 1023) = 112
> close(4) = 0
> open("/proc/8/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "8 (mtdblockd) S 1 1 1 0 -1 2112 "..., 1023) = 121
> close(4) = 0
> open("/proc/9/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "9 (rpciod) S 1 1 1 0 -1 64 0 0 0"..., 1023) = 117
> close(4) = 0
> open("/proc/21/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "21 (inetd) S 1 21 21 0 -1 320 27"..., 1023) = 176
> close(4) = 0
> open("/proc/56/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "56 (avia_av_wdt) S 1 1 1 0 -1 64"..., 1023) = 124
> close(4) = 0
> open("/proc/60/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "60 (avia_gt_wdt) S 1 1 1 0 -1 64"..., 1023) = 124
> close(4) = 0
> open("/proc/80/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "80 (sh) S 1 80 80 1088 90 0 75 8"..., 1023) = 176
> close(4) = 0
> open("/proc/81/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "81 (init) S 1 81 81 1026 81 64 0"..., 1023) = 163
> close(4) = 0
> open("/proc/90/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "90 (strace) R 80 90 80 1088 90 0"..., 1023) = 178
> close(4) = 0
> open("/proc/91/stat", O_RDONLY|O_LARGEFILE) = 4
> read(4, "91 (killall) R 90 90 80 1088 90 "..., 1023) = 162
> close(4) = 0
> getdents64(3, /* 0 entries */, 1024) = 0
> brk(0x10089000) = 0x10089000
> close(3) = 0
> kill(1, SIGTERM) = 0
>
> HK: halt_reboot_pwoff (my debug printout in halt_reboot_pwoff)
> = 0
> call bb_signals
> exit(0) = ?
>
> The system is going down NOW!
> Sending SIGTERM to all processes
> Sending SIGKILL to all processes
> Requesting system reboot
Yes, apparently SIGTERM got caught by init.
> / # strace -fF kill 1
> execve("/bin/kill", ["kill", "1"], [/* 7 vars */]) = 0
> brk(0) = 0x10068a24
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x30017000
...
> mprotect(0xff6e000, 8192, PROT_READ) = 0
> mprotect(0xffc7000, 4096, PROT_READ) = 0
> mprotect(0x30026000, 4096, PROT_READ) = 0
> getuid() = 0
> kill(1, SIGTERM) = 0
> exit(0) = ?
kill() returns 0 (success), so the system thinks that SIGTERM is delivered.
But init does not print your debug message. Very strange.
killall did the very same thing: "kill(1, SIGTERM)" and it worked...
Please try attached idagnostic patch.
It will spam your console if it will detect that init
has TERM blocked or set to unexpected handler.
Try to "kill 1" and "kill -USR1 1" and report what init says.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7.patch
Type: text/x-diff
Size: 800 bytes
Desc: not available
Url : http://busybox.net/lists/busybox/attachments/20080402/8608eb66/attachment-0001.patch
More information about the busybox
mailing list