简体   繁体   中英

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.

The first time it runs properly, but the next time (and also the next ones) it fails with a -1 error code.

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: "); 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.

Following kaylum suggestion I added 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM