Re: ioctl and signal interrupts

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 03/31/04

  • Next message: Birger Blixt: "Re: Thanks"
    Date: Wed, 31 Mar 2004 05:14:32 -0500
    
    

    In article <bc0e3bd8.0403310109.3da1a9a2@posting.google.com>,
     pat.saunders@sis.securicor.co.uk (pat saunders) wrote:

    > Hi,
    > I am using unix (solaris 2.6) and C and Posix (#define
    > _POSIX_SOURCE)!!!
    > In my Code I have noticed that my ioctl systems calls are being
    > interrupted by
    > certain defined signals :
    > ioctl(fd, TCSETS, &tbufsave);
    > ioctl(fd, TCGETS, &tbuf);

    It seems unlikely that these ioctls would be interruptable, since they
    don't have to wait for anything; I'd expect them to be atomic.

    > I am wondering it is sufficient to put
    > do
    > ioctl ...
    > while (errno == EINTR) loop
    > around the system calls, as I have read this can cause problems with
    > certain ioctl calls
    > or do certain kernels like solaris ,automatically restart interuupted
    > systems calls ??

    Some system calls are automatically restarted, others are not, and it
    also depends on whether you set the SA_RESTART option with sigaction().

    Are you sure you're checking the return value of ioctl(), to determine
    whether it actually got an error? It's not correct to check errno
    unless the system call reported an error in the first place.

    -- 
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    

  • Next message: Birger Blixt: "Re: Thanks"