我不知道怎么解决这个问题。
shell后台线程应该忽略SIGHUP信号。
更多信息:
ps -A | grep -E "2442|1007|978"
root 978 1 134760 4860 poll_schedule_timeout 0 S adbd
root 1007 978 33492 2916 sigsuspend 0 S sh
root 2442 1007 33492 3168 0 0 R sh我获取信号:
# strace -p 2442
strace: Process 2442 attached
--- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=1007, si_uid=0} ---
rt_sigreturn({mask=[RTMIN]}) = 264
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
madvise(0x74a7648000, 4096, MADV_DONTNEED) = 0
madvise(0x74a7624000, 4096, MADV_DONTNEED) = 0
fcntl(3, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(4, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(5, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(6, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(29, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(30, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(31, F_GETFD) = -1 EBADF (Bad file descriptor)
close(2) = 0
close(1) = 0
close(0) = 0
mprotect(0x74a8298000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x74a8298000, 4096, PROT_READ) = 0
mprotect(0x74a8298000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x74a8298000, 4096, PROT_READ) = 0
munmap(0x74a8298000, 4096) = 0
exit_group(129) = ?
+++ exited with 129 +++以及父信号信息:
strace -p 1007
strace: Process 1007 attached
read(0, "\4", 1) = 1
write(2, "^D\r\n", 4) = 4
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
write(2, "You have running jobs\n", 22) = 22
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
ioctl(10, TIOCGWINSZ, {ws_row=55, ws_col=102, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost -isig -icanon -echo ...}) = 0
read(0, "\n", 1) = 1
write(2, "\r\n", 2) = 2
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
ioctl(10, TIOCGWINSZ, {ws_row=55, ws_col=102, ws_xpixel=0, ws_ypixel=0}) = 0
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost -isig -icanon -echo ...}) = 0
read(0, "\4", 1) = 1
write(2, "^D\r\n", 4) = 4
ioctl(10, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
kill(-2442, SIGHUP) = 0
--- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
rt_sigreturn({mask=[RTMIN]}) = 0
nanosleep({tv_sec=1, tv_nsec=0}, 0x7ff000fe60) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
rt_sigprocmask(SIG_SETMASK, [RTMIN], [CHLD RTMIN], 8) = 0
ioctl(10, TCGETS, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD RTMIN], [RTMIN], 8) = 0
madvise(0x7ec8048000, 4096, MADV_DONTNEED) = 0
madvise(0x7ec8024000, 4096, MADV_DONTNEED) = 0
fcntl(3, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(4, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(5, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(6, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(7, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(8, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(9, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(10, F_GETFD) = 0x1 (flags FD_CLOEXEC)
close(10) = 0
fcntl(11, F_GETFD) = -1 EBADF (Bad file descriptor)
fcntl(31, F_GETFD) = -1 EBADF (Bad file descriptor)
close(2) = 0
close(1) = 0
close(0) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x7ec8b48000, 4096, PROT_READ) = 0
munmap(0x7ec8b48000, 4096) = 0
exit_group(0) = ?
+++ exited with 0 +++发布于 2022-06-18 15:31:40
使用nohup命令,因此:
nohup command这告诉Android不要用SIGHUP终止进程。运行nohup --help获取更多信息。
https://stackoverflow.com/questions/57141756
复制相似问题