* threaded program turns into "forked"
@ 2003-03-13 16:14 Alvarez Alberto-AALVARB1
2003-03-13 16:45 ` Chuck Winters
0 siblings, 1 reply; 2+ messages in thread
From: Alvarez Alberto-AALVARB1 @ 2003-03-13 16:14 UTC (permalink / raw)
To: linux-c-programming
Hi all,
a work mate has a program which creates up to 5 threads:
( this is done at the "main" module)
for (i=0;i<numeroSM;i++)
{
rc=thr_create(NULL,NULL,RecogerCDRs,(void *)i,NULL,&hilo);
}
but, "sometimes" (horrible expression) a child turns up: new process (new pid), whose parent id and command is the former process.
AFAIK, thread creation can't "fork" a program.
The only data i know is that the second process starts 1 second after the first, which could easily occur while thread creation.
Just in case it's important, we're working with a socket per thread.
Does anyone know whether thread creation could be the reason?
TIA
Alberto Álvarez Besada
Tlf.: +34 914002155
e-mail.: aalvarb1@motorola.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: threaded program turns into "forked"
2003-03-13 16:14 threaded program turns into "forked" Alvarez Alberto-AALVARB1
@ 2003-03-13 16:45 ` Chuck Winters
0 siblings, 0 replies; 2+ messages in thread
From: Chuck Winters @ 2003-03-13 16:45 UTC (permalink / raw)
To: linux-c-programming
On Thu, Mar 13, 2003 at 05:14:45PM +0100, Alvarez Alberto-AALVARB1 wrote:
> Hi all,
> a work mate has a program which creates up to 5 threads:
>
> ( this is done at the "main" module)
> for (i=0;i<numeroSM;i++)
> {
> rc=thr_create(NULL,NULL,RecogerCDRs,(void *)i,NULL,&hilo);
> }
>
> but, "sometimes" (horrible expression) a child turns up: new process (new pid), whose parent id and command is the former process.
> AFAIK, thread creation can't "fork" a program.
>
> The only data i know is that the second process starts 1 second after the first, which could easily occur while thread creation.
> Just in case it's important, we're working with a socket per thread.
>
> Does anyone know whether thread creation could be the reason?
>
> TIA
>
> Alberto ?lvarez Besada
>
> Tlf.: +34 914002155
> e-mail.: aalvarb1@motorola.com
>
>
If you are stating that a new child process turns up when a thread is created,
then what you are explaining is the correct behavior. I believe(someone correct
me if I am wrong), that the pthreads package uses the clone(2) system call which
basically creates a new process with some shared resources. So, each new thread
will have a different process id with the parent being the process which spawned
the thread.
Chuck
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-13 16:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-13 16:14 threaded program turns into "forked" Alvarez Alberto-AALVARB1
2003-03-13 16:45 ` Chuck Winters
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).