linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* fork + signal
@ 2005-07-28 13:51 Suma Choudhary
  0 siblings, 0 replies; 6+ messages in thread
From: Suma Choudhary @ 2005-07-28 13:51 UTC (permalink / raw)
  To: linux-c-programming

hi all
I have this doubt of what happens when a process is still on the way of forking(+ maybe exec further) a child and there comes a sigchld signal.
(Of course assuming that theres a signal handler for the sigchld signal.)

hopeful of getting an answer
regards
suma

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fork + signal
@ 2005-07-28 16:21 r_zaca
  0 siblings, 0 replies; 6+ messages in thread
From: r_zaca @ 2005-07-28 16:21 UTC (permalink / raw)
  To: linux-c-programming

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 367 bytes --]

 Suma, 

 How could a child process send a signal if it is not already created? 

>hi all 
>I have this doubt of what happens when a process is still on the way >of 
>forking(+ maybe exec further) a child and there comes a sigchld >signal. 
>(Of course assuming that theres a signal handler for the sigchld >signal.) 

>hopeful of getting an answer 
>regards 
>suma 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fork + signal
@ 2005-07-29  2:45 Suma Choudhary
  2005-07-29  3:03 ` Ron Michael Khu
  0 siblings, 1 reply; 6+ messages in thread
From: Suma Choudhary @ 2005-07-29  2:45 UTC (permalink / raw)
  To: r_zaca, linux-c-programming

Sorry for being so vague!
OK the situation is like this:
I've a process which after receiving a card insertion message  spawns another process.
Now when the insertion and removal of card is done at a fast rate, the spawning of the child stops after certain time:-(
This when checked with a slower rate works fine.

When the card is removed the child process detects it and kills itself.
THe parent gets a SIGCHLD and "waits" on the child.

Do u see any problem here......should I disable the SIGCHLD before spawning the child?


Thanks for taking the time to consider it.

Regards
suma

>>> r_zaca <r_zaca@ig.com.br> 07/28/05 22:03 PM >>>
 Suma, 

 How could a child process send a signal if it is not already created? 

>hi all 
>I have this doubt of what happens when a process is still on the way >of 
>forking(+ maybe exec further) a child and there comes a sigchld >signal. 
>(Of course assuming that theres a signal handler for the sigchld >signal.) 

>hopeful of getting an answer 
>regards 
>suma 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: fork + signal
  2005-07-29  2:45 fork + signal Suma Choudhary
@ 2005-07-29  3:03 ` Ron Michael Khu
  2005-07-29  4:42   ` Amit Dang
  0 siblings, 1 reply; 6+ messages in thread
From: Ron Michael Khu @ 2005-07-29  3:03 UTC (permalink / raw)
  To: Suma Choudhary, linux-c-programming

state-machine processing problems?

perhaps the mother process was not yet finished performing the function 
for processing the "card insertion message"
when the child process raised a SIGCHLD... perhaps a system call or a 
task done by the parent process was interrupted when the SIGCHLD
was received by the signal handler..

aside from doing a "fork" (and an "exec"), what are other tasks are done 
whenever a card insertion message is received??

can u show some code? both for the parent and child processes



Suma Choudhary wrote:

>Sorry for being so vague!
>OK the situation is like this:
>I've a process which after receiving a card insertion message  spawns another process.
>Now when the insertion and removal of card is done at a fast rate, the spawning of the child stops after certain time:-(
>This when checked with a slower rate works fine.
>
>When the card is removed the child process detects it and kills itself.
>THe parent gets a SIGCHLD and "waits" on the child.
>
>Do u see any problem here......should I disable the SIGCHLD before spawning the child?
>
>
>Thanks for taking the time to consider it.
>
>Regards
>suma
>
>  
>
>>>>r_zaca <r_zaca@ig.com.br> 07/28/05 22:03 PM >>>
>>>>        
>>>>
> Suma, 
>
> How could a child process send a signal if it is not already created? 
>
>  
>
>>hi all 
>>I have this doubt of what happens when a process is still on the way >of 
>>forking(+ maybe exec further) a child and there comes a sigchld >signal. 
>>(Of course assuming that theres a signal handler for the sigchld >signal.) 
>>    
>>
>
>  
>
>>hopeful of getting an answer 
>>regards 
>>suma 
>>    
>>
>
>-
>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] 6+ messages in thread

* Re: fork + signal
  2005-07-29  3:03 ` Ron Michael Khu
@ 2005-07-29  4:42   ` Amit Dang
  0 siblings, 0 replies; 6+ messages in thread
From: Amit Dang @ 2005-07-29  4:42 UTC (permalink / raw)
  To: Suma Choudhary, linux-c-programming

It seems that the main process has not yet finished with the processing of
"insert card" and it was interrupted by SIGCHLD (as pointed out by San Ron
Michael Khu). I am assuming your code to be something like this

Main Process:
{
    CardInserted()
    {
        SpawnChild();
        /*Rest of the processing */
        ....
    }
}

Chlid Process:
{
    CardRemoved()
    {
        /* Processing */

    }
    /* Kill itself */
}

I have few questions (assuming the above code structure):
1 ) After child has detected Card Removal, is CardInserted() function
required to be complete its execution?
2 ) Can SpawnChild() be the last statement of CardInserted() function?
3 ) Is there any kind of locking being used in CardInserted() function?
4 ) Can CardInserted() function be called multiple times simultaneously?

It would be better if you can share the code.

Regards,
Amit Dang
----- Original Message ----- 
From: "Ron Michael Khu" <ronkhu@ntsp.nec.co.jp>
To: "Suma Choudhary" <sumac@myw.ltindia.com>; "linux-c-programming"
<linux-c-programming@vger.kernel.org>
Sent: Friday, July 29, 2005 8:33 AM
Subject: Re: fork + signal


> state-machine processing problems?
>
> perhaps the mother process was not yet finished performing the function
> for processing the "card insertion message"
> when the child process raised a SIGCHLD... perhaps a system call or a
> task done by the parent process was interrupted when the SIGCHLD
> was received by the signal handler..
>
> aside from doing a "fork" (and an "exec"), what are other tasks are done
> whenever a card insertion message is received??
>
> can u show some code? both for the parent and child processes
>
>
>
> Suma Choudhary wrote:
>
> >Sorry for being so vague!
> >OK the situation is like this:
> >I've a process which after receiving a card insertion message  spawns
another process.
> >Now when the insertion and removal of card is done at a fast rate, the
spawning of the child stops after certain time:-(
> >This when checked with a slower rate works fine.
> >
> >When the card is removed the child process detects it and kills itself.
> >THe parent gets a SIGCHLD and "waits" on the child.
> >
> >Do u see any problem here......should I disable the SIGCHLD before
spawning the child?
> >
> >
> >Thanks for taking the time to consider it.
> >
> >Regards
> >suma
> >
> >
> >
> >>>>r_zaca <r_zaca@ig.com.br> 07/28/05 22:03 PM >>>
> >>>>
> >>>>
> > Suma,
> >
> > How could a child process send a signal if it is not already created?
> >
> >
> >
> >>hi all
> >>I have this doubt of what happens when a process is still on the way >of
> >>forking(+ maybe exec further) a child and there comes a sigchld >signal.
> >>(Of course assuming that theres a signal handler for the sigchld
>signal.)
> >>
> >>
> >
> >
> >
> >>hopeful of getting an answer
> >>regards
> >>suma
> >>
> >>
> >
> >-
> >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
> >
> >
> >
> >
>
> -
> 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] 6+ messages in thread

* Re: fork + signal
@ 2005-07-29  7:55 Suma Choudhary
  0 siblings, 0 replies; 6+ messages in thread
From: Suma Choudhary @ 2005-07-29  7:55 UTC (permalink / raw)
  To: amit_dang, linux-c-programming

hi all
The parent process gets a message from FIFO . There was one more signal(when a card is inserted) whose signal handler opens the FIFO(O_WRONLY)to msg to itself while  it has not opened it for reading (busy somewhere else)........so a deadlock!
Thanks for the help otherwise I wud never have read (and re -read) for the FIFO man pages !

regards
suma
ps:check the pseudo code here ........hope I've tracked down the problem right!

The code of parent will be:
main()
{
register signal handlers;
 for(;;)
 {
    open(fifo);
    wait for a msg;
    close(fifo);
    spawn_process;/*was here when the process was opening fifo in signal handler*/
    
  }
}
signal_handler()
{
  open(fifo,O_WRONLY);/*blocked here */
  write(the msg );
  close(fifo);
}
>>> "Amit Dang" <amit_dang@intersolutions.stpn.soft.net> 07/29/05 10:13 AM >>>
It seems that the main process has not yet finished with the processing of
"insert card" and it was interrupted by SIGCHLD (as pointed out by San Ron
Michael Khu). I am assuming your code to be something like this

Main Process:
{
    CardInserted()
    {
        SpawnChild();
        /*Rest of the processing */
        ....
    }
}

Chlid Process:
{
    CardRemoved()
    {
        /* Processing */

    }
    /* Kill itself */
}

I have few questions (assuming the above code structure):
1 ) After child has detected Card Removal, is CardInserted() function
required to be complete its execution?
2 ) Can SpawnChild() be the last statement of CardInserted() function?
3 ) Is there any kind of locking being used in CardInserted() function?
4 ) Can CardInserted() function be called multiple times simultaneously?

It would be better if you can share the code.

Regards,
Amit Dang
----- Original Message ----- 
From: "Ron Michael Khu" <ronkhu@ntsp.nec.co.jp>
To: "Suma Choudhary" <sumac@myw.ltindia.com>; "linux-c-programming"
<linux-c-programming@vger.kernel.org>
Sent: Friday, July 29, 2005 8:33 AM
Subject: Re: fork + signal


> state-machine processing problems?
>
> perhaps the mother process was not yet finished performing the function
> for processing the "card insertion message"
> when the child process raised a SIGCHLD... perhaps a system call or a
> task done by the parent process was interrupted when the SIGCHLD
> was received by the signal handler..
>
> aside from doing a "fork" (and an "exec"), what are other tasks are done
> whenever a card insertion message is received??
>
> can u show some code? both for the parent and child processes
>
>
>
> Suma Choudhary wrote:
>
> >Sorry for being so vague!
> >OK the situation is like this:
> >I've a process which after receiving a card insertion message  spawns
another process.
> >Now when the insertion and removal of card is done at a fast rate, the
spawning of the child stops after certain time:-(
> >This when checked with a slower rate works fine.
> >
> >When the card is removed the child process detects it and kills itself.
> >THe parent gets a SIGCHLD and "waits" on the child.
> >
> >Do u see any problem here......should I disable the SIGCHLD before
spawning the child?
> >
> >
> >Thanks for taking the time to consider it.
> >
> >Regards
> >suma
> >
> >
> >
> >>>>r_zaca <r_zaca@ig.com.br> 07/28/05 22:03 PM >>>
> >>>>
> >>>>
> > Suma,
> >
> > How could a child process send a signal if it is not already created?
> >
> >
> >
> >>hi all
> >>I have this doubt of what happens when a process is still on the way >of
> >>forking(+ maybe exec further) a child and there comes a sigchld >signal.
> >>(Of course assuming that theres a signal handler for the sigchld
>signal.)
> >>
> >>
> >
> >
> >
> >>hopeful of getting an answer
> >>regards
> >>suma
> >>
> >>
> >
> >-
> >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
> >
> >
> >
> >
>
> -
> 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

-
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] 6+ messages in thread

end of thread, other threads:[~2005-07-29  7:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-29  2:45 fork + signal Suma Choudhary
2005-07-29  3:03 ` Ron Michael Khu
2005-07-29  4:42   ` Amit Dang
  -- strict thread matches above, loose matches on Subject: below --
2005-07-29  7:55 Suma Choudhary
2005-07-28 16:21 r_zaca
2005-07-28 13:51 Suma Choudhary

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).