[英]C system call fails from second time on
I am running a program that a given points do a system
call to zip some files.我正在运行一个程序,给定点执行
system
调用以压缩一些文件。
The first time it runs properly, but the next time (and also the next ones) it fails with a -1 error code.第一次运行正常,但下一次(以及下一次)失败并显示 -1 错误代码。
sprintf(zip, "zip -q -T -m -r %s/datsiter%d.zip %s/*%d.dat", dir, it_number, dir, it_number);
ierr = system(zip);
printf("Output:%s %d\n ",zip, ierr);
The output is:输出是:
Output:zip -q -T -m -r results/datsiter0.zip results/*0.dat 0
Output:zip -q -T -m -r results/datsiter1.zip results/*1.dat -1
Output:zip -q -T -m -r results/datsiter2.zip results/*2.dat -1
If after the run I execute the commands manually, it works as expected.如果运行后我手动执行命令,它会按预期工作。
EDIT Following kaylum suggestion I added perror("Error: ");
编辑按照 kaylum 的建议,我添加了
perror("Error: ");
just after system
call and got the key.就在
system
调用之后,拿到了钥匙。 A nice Cannot allocate memory
that I'll have to check carefully since I'm working in a cluster with a queue system.一个很好的
Cannot allocate memory
,我必须仔细检查,因为我在一个带有队列系统的集群中工作。
Following kaylum suggestion I added perror("Error: ");按照 kaylum 的建议,我添加了 perror("Error:"); just after system call and got the key.
就在系统调用之后,拿到了钥匙。 A nice Cannot allocate memory that I'll have to check carefully since I'm working in a cluster with a queue system.
一个很好的无法分配内存,我必须仔细检查,因为我在一个带有队列系统的集群中工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.