Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2001 14:53:24 -0500 (EST)
From:      David Miller <dmiller@sparks.net>
To:        freebsd-hackers@freebsd.org
Subject:   [OT] alarm() question
Message-ID:  <Pine.BSF.4.21.0111301452350.27497-100000@search.sparks.net>

next in thread | raw e-mail | index | archive | help
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 <stdio.h>
#include <unistd.h>
#include <signal.h>

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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0111301452350.27497-100000>