![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Forking in Unix using C++ | kkk02 | High Level Programming | 3 | 5 Days Ago 06:53 AM |
| forking process. | kymthasneem | High Level Programming | 2 | 06-23-2007 10:00 AM |
| Forking | manjuWicky | UNIX for Advanced & Expert Users | 3 | 10-07-2005 12:01 PM |
| Forking in a loop | manjuWicky | High Level Programming | 1 | 10-07-2005 09:25 AM |
| How to cancel a thread safely from the initial thread? | alan.zhao | High Level Programming | 1 | 04-29-2005 07:07 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
forking within a thread
Is it safe to call fork+exec in a multithreaded application.
Because In my multithreaded application, I need to execute another program in each thread. I am using solaris 10. Any suggestions pls. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Yeah, it's safe in a general sense. I believe that Solaris 10 has fork1() available (and if it does, forkall() would be there too). fork1() is supposed to replicate only the current thread in the new process and there may be a performance boost available by that. But I have not used fork1()/forkall() so I'm not sure. Anyway, I would give fork1() a try.
|
|
#3
|
|||
|
|||
|
Each thread may call fork() then exec() if that is what you mean?
The rules are that are that after fork() only one thread is running in the child process, and that was the thread that called fork(). Also have a look at pthread_atfork() and see if you need to do anything to protect mutexes etc. |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|