Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Feb 1999 14:06:10 -0800
From:      Don Lewis <Don.Lewis@tsc.tdk.com>
To:        John Polstra <jdp@polstra.com>, nsmart@kira.team400.ie
Cc:        hackers@FreeBSD.ORG
Subject:   Re: select() can set errno to ECHILD?
Message-ID:  <199902162206.OAA14029@salsa.gv.tsc.tdk.com>
In-Reply-To: John Polstra <jdp@polstra.com> "Re: select() can set errno to ECHILD?" (Feb 15,  4:17pm)

next in thread | previous in thread | raw e-mail | index | archive | help
On Feb 15,  4:17pm, John Polstra wrote:
} Subject: Re: select() can set errno to ECHILD?
} In article <36C85A77.EDBC00F9@kira.team400.ie>,
} Niall Smart  <nsmart@kira.team400.ie> wrote:
} > Erik E Rantapaa wrote:
} > > 
} > > I have code running under 2.2.x which claims that this is happening.
} > > This behaviour is not documented in the man pages.  I have not been able to
} > > duplicate it in a simple test program I wrote, but the log files for
} > > a Merit RADIUS server say that it is happening.
} > > 
} > > Is this at all possible?
} > 
} > You are getting SIGCHLD while blocked in select, waitpid with WNOHANG in
} > then handler returns ECHILD, the signal handler fails to restore errno.
} 
} But when the signal handler returns, it will return to select()
} again, right?  And select will either continue and eventually succeed
} returning some number >= 0, or it will itself set errno (perhaps to
} EINTR) and return -1, right?  So if the caller of select checks its
} return value and only looks at errno if the return value is -1, I
} can't see how anything the signal handler does could confuse it.

The signal handler could be invoked and stomp errno after select() returns
and before the userland code looks at errno.  This isn't real likely
to happen, but you'll probably get bitten by this sooner or later.

} In other words, if there is a bug in the application then it must be
} that the application fails to check the return value of select before
} examining errno.

Code that fails to check the return value of a syscall before looking
at errno will tend to fail pretty frequently.


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?199902162206.OAA14029>