Reputation: 5039
I have a C++ program which is mainly used for video processing. Inside the program, I am launching the system
command in order to obtain pass the processed videos to some other binaries to postprocess them.
I have a while loop towards infinite and I am launching the system command inside the loop every time. The thing is that at a certain point I am receiving the -1 return code from the system
command. What could be the reason for that?
Inside the system command I am just calling a binary file with the adequate parameters from the main project.
The system
command which I want to execute is actually a shell file.
In this file I am extracting the main feature from the video and passing them through a SVM model from a 3D party library in order to obtain the the desired classification.
./LiveGestureKernel ./Video ./SvmVideo
./mat4libsvm31 -l SvmVideoLabels < SvmVideo > temp_test_file
./svm-predict temp_test_file svm_model temp_output_file
cat < temp_output_file
rm -f temp_*
After a certain number of iterations through the while loop, it just won't execute the script file and I cannot figure out the reason for this. Thanks!
Upvotes: 0
Views: 481
Reputation: 881323
If you get -1
from the call to system()
, you should first examine the contents of errno
- that will most likely tell you what your specific problem is.
The one thing to watch out for is that the return value from system
is an implementation-defined one in the case where you pass it a non-NULL command, so it's possible that -1
may be coming from your actual executable.
Your best bet in that case is to print out (or otherwise log) the command being executed on failure (and possibly all the time), so that you can check what happens with the same arguments when you execute it directly from a command line or shell.
Upvotes: 3