我希望找到一个类似strace的UbuntuLinux16.04系统命令,以了解为什么我的C++程序ServiceController.exe
[execle ("/usr/lib/mono/4.5/mono-service","/usr/lib/mono/4.5/mono-service",
"./Debug/ComputationalImageClientServer.exe",
0, char const* EnvironmentPtr)]在90秒后神秘地停止运行*其中* ComputationalImageClientServer.exe和ComputatationalImageClientServer.exe是C#/.NET 4.5可执行文件
In contrast, when I run /usr/lib/mono/4.5/mono-service.exe ./Debug/ComputatationalImageVideoServer.exe" at the command prompt,它连续运行24小时,至少7天。
为什么第一个示例不能连续运行24X7?如何诊断、调试和修复此错误?
open("Delaware_Client_Server.exe", O_RDONLY) = 3
pipe2([4, 5], O_CLOEXEC) = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f743e4dca10) = 3509
close(5) = 0
fcntl(4, F_SETFD, 0) = 0
fstat(4, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
read(4, "", 4096) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3509, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
close(4) = 0
wait4(3509, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 3509
write(1, "\n", 1) = 1
write(1, "Process returned 256\n", 21) = 21发布于 2016-05-28 11:38:16
使用GNU调试器、gdb或类似的工具。
发布于 2016-05-30 06:02:31
以守护进程的形式运行程序与使用“&”将程序分叉到后台有什么区别呢?
可能是SIGHUP的州是导致ServiceController.exe在90秒后停止运行的罪魁祸首。nohup命令&防止这种情况发生。
使用命令&当父进程死亡时,您的进程将被SIGHUP信号杀死。
不过,系统管理员可以找到一些解决办法。
在bash系统上,可以使用:(陷阱‘HUP;命令)&
这将打开一个子subshell,用一个空处理程序捕获HUP信号,然后对它进行符号/分叉。
输出仍然可能被重定向到错误的tty。或者迷路。您可以使用&>command.out、1>output.out或2>errors.out修复这个问题。
在大多数系统上,您还可以访问nohup命令。nohup大大简化了这个过程。这是相当标准的,但我发现许多busybox嵌入式ARM发行版都缺少它。您只需写: nohup命令&
..and,你完了。输出被重定向到nohup.out,但是这个文件名可以用一个选项来更改。
https://unix.stackexchange.com/questions/286080
复制相似问题