Created
October 3, 2012 12:33
-
-
Save AlexsJones/3826696 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int kill_spawn() | |
| { | |
| pid_t parent = getpid(); | |
| //Isn't this an ugly way of doing ATOI, but hey thats the way it goes | |
| stringstream parent_string; | |
| parent_string << parent; | |
| cout << "Current process ID is : " << parent << endl; | |
| if(system("ps -ax | grep launch_pad > /tmp/process.tmp") != 0) | |
| { | |
| return 1; | |
| } | |
| ifstream fs("/tmp/process.tmp"); | |
| string line; | |
| while(fs.good()) | |
| { | |
| getline(fs,line); | |
| if(line != "") | |
| { | |
| vector<string> chopper = jnx_string::split(line," "); | |
| cout << chopper[0] << endl; | |
| if(chopper[0] != parent_string.str()) | |
| { | |
| stringstream ss; | |
| ss << "kill -9 " << chopper[0]; | |
| system(ss.str().c_str()); | |
| } | |
| } | |
| } | |
| system("rm /tmp/process.tmp"); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment