Why would a person want to ignore SIGINT?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Why would a person want to ignore SIGINT?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Why would a person want to ignore SIGINT?  
K-mart Cashier


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-03-07 06:21 AM

This isn't a homework question. This is something I've seen some Unix
programmers do. I really can't think of any reason why a person would
intentionally do this.

Chad






[ Post a follow-up to this message ]



    Re: Why would a person want to ignore SIGINT?  
Logan Shaw


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-03-07 06:21 AM

K-mart Cashier wrote:
> This isn't a homework question. This is something I've seen some Unix
> programmers do. I really can't think of any reason why a person would
> intentionally do this.

Well, maybe this is a contrived example, but it seems valid nonetheless.

Suppose you write a program that fork()s into 1 supervisor process and
5 worker processes, and suppose the worker processes regularly and
frequently check with the supervisor to request more work units.  You
want to support exiting via a signal, but the design of the workers
could be cleaner if you assume they exit only when told to by the
supervisor process.  (And maybe it's not critical but is still
helpful if they can complete the work unit that's in progress.)

Now, if you run this program from a normal Unix shell, all 6 processes
are going to end up in a process group together, and when the user hits
control-C (or whatever the intr character is), it is going to send the
SIGINT to the every process in the process group.

In this case, you'd want your supervisor process to receive the signal
but you'd want the worker processes to ignore it, since they will be
informed of it by the supervisor after they finish their work unit
anyway and since there is nothing useful they can do with it should
they receive it.

- Logan





[ Post a follow-up to this message ]



    Re: Why would a person want to ignore SIGINT?  
K-mart Cashier


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
03-03-07 06:21 AM

On Mar 2, 7:10 pm, Logan Shaw <lshaw-use...@austin.rr.com> wrote:
> K-mart Cashier wrote: 
>
> Well, maybe this is a contrived example, but it seems valid nonetheless.
>
> Suppose you write a program that fork()s into 1 supervisor process and
> 5 worker processes, and suppose the worker processes regularly and
> frequently check with the supervisor to request more work units.  You
> want to support exiting via a signal, but the design of the workers
> could be cleaner if you assume they exit only when told to by the
> supervisor process.  (And maybe it's not critical but is still
> helpful if they can complete the work unit that's in progress.)
>
> Now, if you run this program from a normal Unix shell, all 6 processes
> are going to end up in a process group together, and when the user hits
> control-C (or whatever the intr character is), it is going to send the
> SIGINT to the every process in the process group.
>
> In this case, you'd want your supervisor process to receive the signal
> but you'd want the worker processes to ignore it, since they will be
> informed of it by the supervisor after they finish their work unit
> anyway and since there is nothing useful they can do with it should
> they receive it.
>
>


Hmmm.... This is sort of depressing because I had actually thought
about the question before I posted it on comp.unix.programmer. I think
what is perhaps
even more depressing is the fact Logan's example never once occurred
to me. Had this been a job interview question, I think the interview
would have ended
right then and there,







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:38 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register