Hello everybody, i need to write a little program that allow me to run a linux script.
I did something like that
Code:
#include "string"
#include "iostream"
#include "fstream"
#define PIPE "/tmp/pipe"
using namespace std;
int main()
{
FILE *fp;
ifstream c1;
char *command;
while(1)
{
c1.open(PIPE);
sleep(1);
if(c1.is_open())
{
command = new char[256];
while(!c1.eof())
{
c1.getline(command,256,'\n');
system(command);
}
sleep(1);
c1.close();
remove(PIPE);
}
}
}
and the main program write the name of the script in a pipe file.
but when i make ps , further my process i can see two line like this
Code:
3405 root 496 S sh -c /myfolder/myscript
3406 root 528 S /bin/sh /myfolder/myscript
anyone can explain me why
Regards