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

Originator:indieami
Number:rdar://7952709 Date Originated:05/06/2010
Status:Open Resolved:
Product:OS X Product Version:
Classification: Reproducible:Always
 
Summary:
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
cat

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

Regression:

Notes:
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.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com 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!