There are 3 id in you process
getpid(), getpgid(getpid()), getsid(getpid()).
1. caller side
#use posix_spawn get spawn id and wait until target independently
pid_t spawnid;
pid_t targetid;
char* args[] = {"targetname", "usb", "1", "2", NULL};
posix_spawn(&spawnid, "/root/hdapi/targetname/bin/targetname", NULL, NULL, args, environ);
targetid = 0;
while( targetid != spawnid ) //wait targetname totally independent {
targetid = getsid(spawnid);
usleep(1000);
}
2. target side
execute setsid() make the process independently
getpid(), getpgid(getpid()), getsid(getpid()). all the same after execute setsid().
download:
https://www.mediafire.com/file/e88rpu2038frh5u/start_process.tar.gz
沒有留言:
張貼留言