Quote:
Originally Posted by
Raj Kumar Arora
And I dont want to create a new process in a thread.
The function system() takes a string which will be parsed by the shell, this can have as many arguments as the system will permit.
Under UNIX, the only way you can run a program is by "exec" which replaces the current program image with the new program.
If you want your program to continue running you have to call fork() or vfork() to create a new process, tough, but that is UNIX.
Yes, threads and fork can be a nightmare, what exactly is the problem? If it's resource contention/locking I suggest you have a look at "pthread_atfork()".
If you need to spawn a new process from a multithreaded program you have no options other than
(a) using fork/vfork
(b) calling a a function that wraps them up
(c) use IPC to talk to another program to create the new process