read() system call is not restarted when interrupted by SIGTTIN

Number:rdar://7952709 Date Originated:05/06/2010
Status:Open Resolved:
Product:OS X Product Version:
Classification: Reproducible:Always
The read() system call does not appear to be restarted when interrupted by SIGTTIN.  Instead, read() returns EINTR, which many programs do not expect.

Steps to Reproduce:
This is trivially repeatable with cat(1) by putting it in the background, and then foregrounding the process.

Expected Results:
Other operating systems restart the read(), and cat resumes, like so:

bash-3.2$ cat &
[1] 13082
bash-3.2$ fg

Actual Results:
bash-3.2$ cat &
[1] 46363
bash-3.2$ %1
cat: stdin: Interrupted system call


This is not a bug in cat.

It's worth noting that this happens regardless of whether SA_RESTART is set.

Fom a quick scan of the xnu tty code the problem may simply be that ttread(), ttywrite() and ttioctl() return EINTR instead of ERESTART.  Other BSD tty implementations use ttysleep() in these locations.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!