2017-02-25 47 views
0

我想通过python应用程序使用Frama-c。这个python应用程序设置了一些env变量和系统路径。从这个应用程序,我打电话邮资-C作为一个python程序如下:OCaml引发的“无子进程”错误Sys.command函数

cmd = ['/usr/local/bin/frama-c', '-wp', '-wp-print', '-wp-out', '/home/user/temp','/home/user/project/test.c'] 
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=False) 

当这个代码是从Python应用程序我收到以下错误执行:

[kernel] Parsing FRAMAC_SHARE/libc/__fc_builtin_for_normalization.i (no preprocessing) 
[kernel] warning: your preprocessor is not known to handle option ` -nostdinc'. If pre-processing fails because of it, please add -no-cpp-gnu-like option to Frama-C's command-line. If you do not want to see this warning again, use explicitely -cpp-gnu-like option. 
[kernel] warning: your preprocessor is not known to handle option `-dD'. If pre-processing fails because of it, please add -no-cpp-gnu-like option to Frama-C's command-line. If you do not want to see this warning again, use explicitely -cpp-gnu-like option. 
[kernel] Parsing 2675891095.c (with preprocessing) 
[kernel] System error: /usr/bin/gcc -c -C -E -I. -dD -nostdinc -D__FC_MACHDEP_X86_32 -I/usr/local/share/frama-c/libc -o '/tmp/2675891095.cc8bf16.i' '/home/user/project/test.c': No child processes 

我很难找到它调试是什么造成的错误:

System error: /usr/bin/gcc -c -C -E -I. -dD -nostdinc -D__FC_MACHDEP_X86_32 -I/usr/local/share/frama-c/libc -o '/tmp/2675891095.cc8bf16.i' '/home/user/project/test.c': No child processes

有没有办法从Frama-c生成更多的错误日志,可以帮助我找出问题?

请注意,只有当我从我的应用程序启动进程(执行Frama-c)时才会出现此错误,而不是从python控制台启动它。它只发生在Linux机器而不是Windows机器上。

任何帮助表示赞赏。谢谢!!

更新: 我意识到通过使用-kernel-debug标志我可以获得堆栈跟踪。所以,我想的选项,并获得以下信息:

Fatal error: exception Sys_error("gcc -E -C -I. -dD -D__FRAMAC__ -nostdinc -D__FC_MACHDEP_X86_32 -I/usr/local/share/frama-c/libc -o '/tmp/2884428408.c2da79b.i' '/home/usr/project/test.c': No child processes")

Raised by primitive operation at file "src/kernel_services/ast_queries/file.ml", line 472, characters 9-32

Called from file "src/kernel_services/ast_queries/file.ml", line 517, characters 14-26

Called from file "src/kernel_services/ast_queries/file.ml", line 703, characters 46-59

Called from file "list.ml", line 84, characters 24-34

Called from file "src/kernel_services/ast_queries/file.ml", line 703, characters 17-76

Called from file "src/kernel_services/ast_queries/file.ml", line 1587, characters 24-47

Called from file "src/kernel_services/ast_queries/file.ml", line 1667, characters 4-27

Called from file "src/kernel_services/ast_data/ast.ml", line 108, characters 2-28

Called from file "src/kernel_services/ast_data/ast.ml", line 116, characters 53-71

Called from file "src/kernel_internals/runtime/boot.ml", line 29, characters 6-20

Called from file "src/kernel_services/cmdline_parameters/cmdline.ml", line 787, characters 2-9

Called from file "src/kernel_services/cmdline_parameters/cmdline.ml", line 817, characters 18-64

Called from file "src/kernel_services/cmdline_parameters/cmdline.ml", line 228, characters 4-8

Re-raised at file "src/kernel_services/cmdline_parameters/cmdline.ml", line 244, characters 12-15

Called from file "src/kernel_internals/runtime/boot.ml", line 72, characters 2-127

而且我看了看文件"src/kernel_services/ast_queries/file.ml", line 472和执行的代码是Sys.command cpp_command

我不确定为什么在尝试执行执行gcc时会抛出“No Child Processes”错误。

更新:我有ocaml的版本:4.02.3,Python版本:2.7.8和邮资-C版本:硅20161101

+0

它可能有助于知道你在哪个系统上运行:Linux,Windows,macOS? –

+0

它仅在Linux机器上发生,而不在Windows机器上发生。 – user2888308

+0

你还可以指定你正在使用的OCaml和Python的版本吗?有一些相关问题(如[this one](https://caml.inria.fr/mantis/view.php?id=5256))仅适用于特定版本的Python和/或OCaml。 – anol

回答

0

我什么都不知道邮资-C。但是,错误消息来自某人(OCaml's?Python's?)运行时,表明系统调用失败,出现ECHILD错误。 system()所做的两个系统调用是fork()waitpid()。这是后面的系统调用,可以返回ECHILD。这意味着没有儿童流程需要等待。一个很好的可能性是fork()失败。当系统充满进程(不太可能)或达到每用户进程限制时,fork()会失败。你可以检查你是否遇到这种限制。

另一种可能性出现在我身上的是代码的其他部分已经在使用信号处理来处理子进程(SIGCHLD)。所以没有儿童流程等待的原因是它已经在其他地方处理过了。这很复杂,所以我希望这不是问题。