Hey I was just messing around with g++ on mac to make programs that would execute other terminal commands. I ran into a situation that I don't quite understand and was curious of this is expected behavior.
Shared Lib:
Code:
void printAllArgs(int argc, char *argv[]){
using std::cout;
using std::endl;
for(int i = 0; i < argc; i++){
cout<<i<<" => "<<argv[i]<<endl;
}
}
sweet.exe
Code:
#include <iostream>
#include "lib.h"
int main( int argc, char *argv[] ){
printAllArgs(argc, argv);
system("./dude What does mine say?");
return 0;
}
dude.exe
Code:
#include <iostream>
#include "lib.h"
int main( int argc, char *argv[] ){
printAllArgs(argc, argv);
system("./sweet What does mine say?");
return 0;
}
Expected: To run indefinitely until I killed the terminal thread.
Saw: After about 30 seconds the terminal output stops.