Yes use fork then execlp(or one of the family of functions from exec).
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
I think this is what you want:
main.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define APP_PATH "/path_to_testit/testit"
int main(int argc, char**argv)
{
if (fork())
{
fprintf(stdout, "parent pid->%d\n", getpid());
}
else
{
execlp(APP_PATH, APP_PATH, "some value");
}
exit(EXIT_SUCCESS);
}
testit.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char**argv)
{
fprintf(stdout, "we passed->%s\n", argv[1]);
fprintf(stdout, "client's parent->%d\n", getppid());
exit(EXIT_SUCCESS);
}
gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387