Automatically restarting system calls?

Rhamphoryncus rhamph at gmail.com
Sat Jun 14 13:04:15 EDT 2008


On Jun 13, 10:41 am, Dan Stromberg <dstrombergli... at gmail.com> wrote:
> I wrote a script(1) replacement in python (http://stromberg.dnsalias.org/
> ~dstromberg/pypty/), but I'm encountering a problem in it.
>
> I think I know the solution to the problem, but I'd've thought python was
> high level enough that this solution isn't required, so I wanted to
> inquire about it here.
>
> Specifically, the program has a signal handler for window size changes.
> And if the window is resized during an os.write() (for example), I get a
> python exception about needing to restart the system call.
>
> In C, I know you're supposed to wrap your system calls with while loops
> until you don't get an ERESTART, but does one really need to wrap all of
> one's os.write()'s (for example) with such while loops in python?

Unfortunately, signals are sometimes used to intentionally interrupt
system calls, so we can't always loop on ERESTART.

However, os.write() is a low level API.  Maybe file.write() or
socket.send() would be a little more robust?



More information about the Python-list mailing list