考虑以下脚本(称为 main_script):
#!/bin/bash
# Configuration steps
.
.
wrapper <arguments>
# Other tasks
.
.
wrapper <arguments>
# Some more tasks
.
.
主脚本启动几个脚本并让它们在后台运行。这个主脚本通常来自第三方 - 因此我无法控制它。完成后,main_script 就会退出。现在我需要将包装器启动的进程与 main_script 关联起来,即我需要跟踪 main_script 启动了哪些进程。有人可以建议一种方法来做到这一点吗?
这里使用的包装器是tanuki Java 服务包装器。
如果问题不清楚,请告诉我。
答案1
除非我误解了你的问题,否则如果你需要更多细节,你不能使用“bash -x main_script”或“strace -f ./main_script”吗?
测试脚本:
[user@host ~]$ cat test.sh && cat script1
#!/bin/bash
./script1
#!/bin/bash
echo 'hi!'
重击
[user@host ~]$ bash -x test.sh
+ ./script1
hi!
或 strace -f
[user@host ~]$ strace -f ./test.sh
execve("./test.sh", ["./test.sh"], [/* 24 vars */]) = 0
brk(0) = 0x143a000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1fab27a000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=17630, ...}) = 0
mmap(NULL, 17630, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1fab272000
close(3) = 0
open("/lib64/libtinfo.so.5", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\310\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=135896, ...}) = 0
mmap(NULL, 2232320, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1faae37000
mprotect(0x7f1faae54000, 2097152, PROT_NONE) = 0
mmap(0x7f1fab054000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1d000) = 0x7f1fab054000
close(3) = 0
open("/lib64/libdl.so.2", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19536, ...}) = 0
mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1faac33000
mprotect(0x7f1faac35000, 2097152, PROT_NONE) = 0
mmap(0x7f1faae35000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f1faae35000
close(3) = 0
open("/lib64/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1916568, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1fab271000
mmap(NULL, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1faa8a0000
mprotect(0x7f1faaa2a000, 2093056, PROT_NONE) = 0
mmap(0x7f1faac29000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x7f1faac29000
mmap(0x7f1faac2e000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1faac2e000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1fab270000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1fab26f000
arch_prctl(ARCH_SET_FS, 0x7f1fab270700) = 0
mprotect(0x7f1faac29000, 16384, PROT_READ) = 0
mprotect(0x7f1faae35000, 4096, PROT_READ) = 0
mprotect(0x7f1fab277000, 4096, PROT_READ) = 0
munmap(0x7f1fab272000, 17630) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("/dev/tty", O_RDWR|O_NONBLOCK) = 3
close(3) = 0
brk(0) = 0x143a000
brk(0x145b000) = 0x145b000
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=99158576, ...}) = 0
mmap(NULL, 99158576, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1fa4a0f000
close(3) = 0
getuid() = 500
getgid() = 500
geteuid() = 500
getegid() = 500
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("/proc/meminfo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1fab276000
read(3, "MemTotal: 3923232 kB\nMemF"..., 1024) = 1024
close(3) = 0
munmap(0x7f1fab276000, 4096) = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
uname({sys="Linux", node="host.example.com", ...}) = 0
stat("/home/user", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
getpid() = 28822
open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=26060, ...}) = 0
mmap(NULL, 26060, PROT_READ, MAP_SHARED, 3, 0) = 0x7f1fab268000
close(3) = 0
getppid() = 28819
getpgrp() = 28819
rt_sigaction(SIGCHLD, {0x43f2b0, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
getrlimit(RLIMIT_NPROC, {rlim_cur=1024, rlim_max=30504}) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
open("./test.sh", O_RDONLY) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffecf31ec0) = -1 ENOTTY (Inappropriate ioctl for device)
lseek(3, 0, SEEK_CUR) = 0
read(3, "#!/bin/bash\n./script1\n", 80) = 22
lseek(3, 0, SEEK_SET) = 0
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0
fcntl(255, F_GETFD) = -1 EBADF (Bad file descriptor)
dup2(3, 255) = 255
close(3) = 0
fcntl(255, F_SETFD, FD_CLOEXEC) = 0
fcntl(255, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(255, {st_mode=S_IFREG|0755, st_size=22, ...}) = 0
lseek(255, 0, SEEK_CUR) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "#!/bin/bash\n./script1\n", 22) = 22
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
rt_sigprocmask(SIG_BLOCK, [INT CHLD], [], 8) = 0
clone(Process 28823 attached (waiting for parent)
Process 28823 resumed (parent 28822 ready)
child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f1fab2709d0) = 28823
[pid 28822] rt_sigprocmask(SIG_SETMASK, [], <unfinished ...>
[pid 28823] close(255 <unfinished ...>
[pid 28822] <... rt_sigprocmask resumed> NULL, 8) = 0
[pid 28823] <... close resumed> ) = 0
[pid 28822] rt_sigprocmask(SIG_BLOCK, [CHLD], <unfinished ...>
[pid 28823] rt_sigprocmask(SIG_SETMASK, [], <unfinished ...>
[pid 28822] <... rt_sigprocmask resumed> [], 8) = 0
[pid 28823] <... rt_sigprocmask resumed> NULL, 8) = 0
[pid 28822] rt_sigprocmask(SIG_SETMASK, [], <unfinished ...>
[pid 28823] rt_sigaction(SIGTSTP, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, <unfinished ...>
[pid 28822] <... rt_sigprocmask resumed> NULL, 8) = 0
[pid 28823] <... rt_sigaction resumed> {SIG_DFL, [], 0}, 8) = 0
[pid 28822] rt_sigprocmask(SIG_BLOCK, [CHLD], <unfinished ...>
[pid 28823] rt_sigaction(SIGTTIN, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, <unfinished ...>
[pid 28822] <... rt_sigprocmask resumed> [], 8) = 0
[pid 28823] <... rt_sigaction resumed> {SIG_DFL, [], 0}, 8) = 0
[pid 28822] rt_sigaction(SIGINT, {0x43d060, [], SA_RESTORER, 0x7f1faa8d2920}, <unfinished ...>
[pid 28823] rt_sigaction(SIGTTOU, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, <unfinished ...>
[pid 28822] <... rt_sigaction resumed> {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
[pid 28823] <... rt_sigaction resumed> {SIG_DFL, [], 0}, 8) = 0
[pid 28822] wait4(-1, <unfinished ...>
[pid 28823] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
[pid 28823] rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {SIG_IGN, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
[pid 28823] rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {0x43f2b0, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
[pid 28823] execve("./script1", ["./script1"], [/* 24 vars */]) = 0
[pid 28823] brk(0) = 0x1d79000
[pid 28823] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbd420c9000
[pid 28823] access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
[pid 28823] open("/etc/ld.so.cache", O_RDONLY) = 3
[pid 28823] fstat(3, {st_mode=S_IFREG|0644, st_size=17630, ...}) = 0
[pid 28823] mmap(NULL, 17630, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbd420c1000
[pid 28823] close(3) = 0
[pid 28823] open("/lib64/libtinfo.so.5", O_RDONLY) = 3
[pid 28823] read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\310\0\0\0\0\0\0"..., 832) = 832
[pid 28823] fstat(3, {st_mode=S_IFREG|0755, st_size=135896, ...}) = 0
[pid 28823] mmap(NULL, 2232320, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbd41c86000
[pid 28823] mprotect(0x7fbd41ca3000, 2097152, PROT_NONE) = 0
[pid 28823] mmap(0x7fbd41ea3000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1d000) = 0x7fbd41ea3000
[pid 28823] close(3) = 0
[pid 28823] open("/lib64/libdl.so.2", O_RDONLY) = 3
[pid 28823] read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\340\r\0\0\0\0\0\0"..., 832) = 832
[pid 28823] fstat(3, {st_mode=S_IFREG|0755, st_size=19536, ...}) = 0
[pid 28823] mmap(NULL, 2109696, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbd41a82000
[pid 28823] mprotect(0x7fbd41a84000, 2097152, PROT_NONE) = 0
[pid 28823] mmap(0x7fbd41c84000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fbd41c84000
[pid 28823] close(3) = 0
[pid 28823] open("/lib64/libc.so.6", O_RDONLY) = 3
[pid 28823] read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\355\1\0\0\0\0\0"..., 832) = 832
[pid 28823] fstat(3, {st_mode=S_IFREG|0755, st_size=1916568, ...}) = 0
[pid 28823] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbd420c0000
[pid 28823] mmap(NULL, 3745960, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fbd416ef000
[pid 28823] mprotect(0x7fbd41879000, 2093056, PROT_NONE) = 0
[pid 28823] mmap(0x7fbd41a78000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x189000) = 0x7fbd41a78000
[pid 28823] mmap(0x7fbd41a7d000, 18600, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fbd41a7d000
[pid 28823] close(3) = 0
[pid 28823] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbd420bf000
[pid 28823] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbd420be000
[pid 28823] arch_prctl(ARCH_SET_FS, 0x7fbd420bf700) = 0
[pid 28823] mprotect(0x7fbd41a78000, 16384, PROT_READ) = 0
[pid 28823] mprotect(0x7fbd41c84000, 4096, PROT_READ) = 0
[pid 28823] mprotect(0x7fbd420c6000, 4096, PROT_READ) = 0
[pid 28823] munmap(0x7fbd420c1000, 17630) = 0
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] open("/dev/tty", O_RDWR|O_NONBLOCK) = 3
[pid 28823] close(3) = 0
[pid 28823] brk(0) = 0x1d79000
[pid 28823] brk(0x1d9a000) = 0x1d9a000
[pid 28823] open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
[pid 28823] fstat(3, {st_mode=S_IFREG|0644, st_size=99158576, ...}) = 0
[pid 28823] mmap(NULL, 99158576, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbd3b85e000
[pid 28823] close(3) = 0
[pid 28823] getuid() = 500
[pid 28823] getgid() = 500
[pid 28823] geteuid() = 500
[pid 28823] getegid() = 500
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] open("/proc/meminfo", O_RDONLY) = 3
[pid 28823] fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
[pid 28823] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbd420c5000
[pid 28823] read(3, "MemTotal: 3923232 kB\nMemF"..., 1024) = 1024
[pid 28823] close(3) = 0
[pid 28823] munmap(0x7fbd420c5000, 4096) = 0
[pid 28823] rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], 0}, 8) = 0
[pid 28823] rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, 8) = 0
[pid 28823] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], 0}, 8) = 0
[pid 28823] rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, 8) = 0
[pid 28823] rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], 0}, 8) = 0
[pid 28823] rt_sigaction(SIGQUIT, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, 8) = 0
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] rt_sigaction(SIGQUIT, {SIG_IGN, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, 8) = 0
[pid 28823] uname({sys="Linux", node="host.example.com", ...}) = 0
[pid 28823] stat("/home/user", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 28823] stat(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 28823] getpid() = 28823
[pid 28823] open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
[pid 28823] fstat(3, {st_mode=S_IFREG|0644, st_size=26060, ...}) = 0
[pid 28823] mmap(NULL, 26060, PROT_READ, MAP_SHARED, 3, 0) = 0x7fbd420b7000
[pid 28823] close(3) = 0
[pid 28823] getppid() = 28822
[pid 28823] getpgrp() = 28819
[pid 28823] rt_sigaction(SIGCHLD, {0x43f2b0, [], SA_RESTORER, 0x7fbd41721920}, {SIG_DFL, [], SA_RESTORER, 0x7fbd41721920}, 8) = 0
[pid 28823] getrlimit(RLIMIT_NPROC, {rlim_cur=1024, rlim_max=30504}) = 0
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] open("./script1", O_RDONLY) = 3
[pid 28823] ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff325f2a00) = -1 ENOTTY (Inappropriate ioctl for device)
[pid 28823] lseek(3, 0, SEEK_CUR) = 0
[pid 28823] read(3, "#!/bin/bash\necho 'hi!'\n", 80) = 23
[pid 28823] lseek(3, 0, SEEK_SET) = 0
[pid 28823] getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0
[pid 28823] fcntl(255, F_GETFD) = -1 EBADF (Bad file descriptor)
[pid 28823] dup2(3, 255) = 255
[pid 28823] close(3) = 0
[pid 28823] fcntl(255, F_SETFD, FD_CLOEXEC) = 0
[pid 28823] fcntl(255, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
[pid 28823] fstat(255, {st_mode=S_IFREG|0755, st_size=23, ...}) = 0
[pid 28823] lseek(255, 0, SEEK_CUR) = 0
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] read(255, "#!/bin/bash\necho 'hi!'\n", 23) = 23
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
[pid 28823] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fbd420b6000
[pid 28823] write(1, "hi!\n", 4hi!
) = 4
[pid 28823] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
[pid 28823] read(255, "", 23) = 0
[pid 28823] exit_group(0) = ?
Process 28823 detached
<... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 28823
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
wait4(-1, 0x7fffecf3195c, WNOHANG, NULL) = -1 ECHILD (No child processes)
rt_sigreturn(0xffffffffffffffff) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f1faa8d2920}, {0x43d060, [], SA_RESTORER, 0x7f1faa8d2920}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
read(255, "", 22) = 0
exit_group(0) = ?
答案2
如果你知道衍生子进程的父进程 PID,你可以使用以下命令列出它们
pgrep -P PPID
您可以使用“$$”脚本中的变量来为当前 shell 获取它。
或者你可以尝试使用“$!” “包装器”行后的变量扩展到最近执行的后台命令的 PID。