Re: [OT] alarm() question

2001-12-01 Thread Eric Melville

> Uh, I'm not sure what to make of that mangling of my name. However, I
> think the pointer to Steven's book you provided may be the thing he
> needs. I certainly don't know what he needs based on his followup.

I'm really sorry for messing up your name like that. I suppose your domain
name was sticking in my head for some reason.

I don't think I got the response that you are talking about, but from what
he has sent me I think that Stevens will provide the answer.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: [OT] alarm() question

2001-12-01 Thread Mike Meyer

Eric Melville <[EMAIL PROTECTED]> types:
> > The system call is being interrupted, it just gets restarted right away by
> > default. See Steven's "UNIX Network Programming" for a means of avoiding
> > this behavior.
> Of course, I'm completely wrong because we're not even talking about a
> system call here. Mike Mired already posted what you need.

Uh, I'm not sure what to make of that mangling of my name. However, I
think the pointer to Steven's book you provided may be the thing he
needs. I certainly don't know what he needs based on his followup.

  http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: [OT] alarm() question

2001-11-30 Thread Eric Melville

> The system call is being interrupted, it just gets restarted right away by
> default. See Steven's "UNIX Network Programming" for a means of avoiding
> this behavior.

Of course, I'm completely wrong because we're not even talking about a
system call here. Mike Mired already posted what you need.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: [OT] alarm() question

2001-11-30 Thread Eric Melville

> Why does the alarm go off but not interrupt the system call?  bzzt() is
> executed, but the program doesn't print Done and exit for a minute plus.
> 
> Pointers to FM to RT welcome.

The system call is being interrupted, it just gets restarted right away by
default. See Steven's "UNIX Network Programming" for a means of avoiding
this behavior.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: [OT] alarm() question

2001-11-30 Thread Mike Meyer

David Miller <[EMAIL PROTECTED]> types:
> Apologies for this being  more C than freebsd, but I did say OT in
> the subject...
> 
> In the most basic use of an alarm, like this:
> 
> #include 
> #include 
> #include 
> 
> sig_t
> signal(int sig, sig_t func);
> 
> static void bzzt() {
> printf("In routine bzzt now, timer expired after 3 seconds\n");
> }
> 
> main() {
> 
> signal(SIGALRM, bzzt);
> alarm(3);
> system("/usr/bin/host -t soa 111.0.12.in-addr.arpa");
> printf("Done\n");
> }
> 
> Why does the alarm go off but not interrupt the system call?  bzzt() is
> executed, but the program doesn't print Done and exit for a minute plus.
> 
> Pointers to FM to RT welcome.

Try the system() man page. system() does a fork, then exec's a shell
with the string. So in the child process, the ALARM handling will be
done by the shell, and I'm pretty sure it ignores them. As you
noticed, the parent process gets the alarm.

Checking the wait system page says that wait system calls - like the
one done by the system() library routine - may either be interrupted,
or restarted after the signal handler runs. Guess which one is
happening here.

  http://www.mired.org/home/mwm/
Q: How do you make the gods laugh?  A: Tell them your plans.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



[OT] alarm() question

2001-11-30 Thread David Miller

Apologies for this being  more C than freebsd, but I did say OT in
the subject...

In the most basic use of an alarm, like this:

#include 
#include 
#include 

sig_t
signal(int sig, sig_t func);

static void bzzt() {
printf("In routine bzzt now, timer expired after 3 seconds\n");
}

main() {

signal(SIGALRM, bzzt);
alarm(3);
system("/usr/bin/host -t soa 111.0.12.in-addr.arpa");
printf("Done\n");
}

Why does the alarm go off but not interrupt the system call?  bzzt() is
executed, but the program doesn't print Done and exit for a minute plus.

Pointers to FM to RT welcome.

Thanks,

--- David



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message