On Wednesday 02 April 2008 22:50, Harald Kuethe wrote:
> > ----- Original Message -----
> > From: "Denys Vlasenko" <[EMAIL PROTECTED]>
> > To: "Harald Kuethe" <[EMAIL PROTECTED]>
> > Cc: <[email protected]>
> > 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" <[EMAIL PROTECTED]>
> > > > To: <[email protected]>
> > > > Cc: "Harald Küthe" <[EMAIL PROTECTED]>
> > > > 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
diff -d -urpN busybox.6/init/init.c busybox.7/init/init.c
--- busybox.6/init/init.c 2008-03-31 21:26:19.000000000 +0200
+++ busybox.7/init/init.c 2008-04-02 23:39:52.000000000 +0200
@@ -966,7 +966,21 @@ int init_main(int argc ATTRIBUTE_UNUSED,
run_actions(ASKFIRST);
/* Don't consume all CPU time -- sleep a bit */
- sleep(1);
+ sleep(5);
+{
+ struct sigaction sa;
+ sigset_t sset;
+
+ sigaction(SIGTERM, NULL, &sa);
+ if (sa.sa_handler != halt_reboot_pwoff)
+ bb_error_msg("weird TERM handler: %p", sa.sa_handler);
+ sigprocmask(SIG_BLOCK, NULL, &sset);
+ if (sigismember(&sset, SIGTERM))
+ bb_error_msg("TERM is blocked");
+ sigpending(&sset);
+ if (sigismember(&sset, SIGTERM))
+ bb_error_msg("TERM is pending");
+}
/* Wait for any child process to exit */
wpid = wait(NULL);
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox