-5

Which of the following system calls can return EINTR or EAGAIN/EWOULDBLOCK?

getsockname()
chdir()
bind()
fcntl()
listen()
setsid()
setsockopt()
socket()
stat()
unlink()
access()
accept()
open()
usleep()
dup2()
fork()
waitpid()
wait()
read()
write()

Some of these system calls return EINTR or EAGAIN on error (by the API of man pages).

Also some system calls exist that the API do not refer the EINTR/EAGAIN and however return these.

Please help.

  • 3
    Call me crazy, but this almost sounds like a homework problem... – Drew McGowen Sep 07 '14 at 21:00
  • 1
    Many systems calls can return those error codes. One place to check is the [POSIX 2008/2013 specification](http://pubs.opengroup.org/onlinepubs/9699919799/toc.htm). You can step through each function in turn and check whether EINTR or EAGAIN is a valid error code. Or you can go through the man pages on your system. I don't know of an online resource that lists system calls and error codes on a single page — it would be a big page. – Jonathan Leffler Sep 07 '14 at 21:03
  • 1
    I know that man pages or Open Group specification can be used for such information but I know that many people handle EINTR/EAGAIN error codes for some system calls that do not refer to these either in man pages or in the specification. That might happen because some system calls might use other system calls that return EINTR/EAGAIN. Should I handle EINTR/EAGAIN only if the man page or spec refers it? – Efstathios Chatzikyriakidis Sep 07 '14 at 22:32

1 Answers1

1

I have found the answer. This question should not have been deleted. As a rule only syscalls which are "slow" return EINTR. Slow things are terminal I/O and things which wait (select, wait, sleep, pause, etc).