我正在从 perl CGI 脚本运行 shell 脚本:
#!/usr/bin/perl
my $command = "./script.sh &";
my $pid = fork();
if (defined($pid) && $pid==0) {
# background process
system( $command );
}
shell 脚本如下所示:
#!/bin/sh
trap 'echo trapped' 15
tail -f test.log
当我从浏览器运行 CGI 脚本,然后使用 停止 httpd/etc/init.d/httpd stop
时,脚本会收到 SIGTERM 信号。
我期待脚本作为一个单独的进程运行,而不是与 httpd 绑定。虽然我可以捕获 SIGTERM,但我想了解脚本为什么会收到 SIGTERM。
我在这里做错了什么?我正在运行 RHEL 5.8 和 Apache HTTP 服务器 2.4。
谢谢, 普拉纳夫