I've been tracking down little errors in the APE select() function that cropped 
up when trying to use Python's subprocess module.  After a few too many hours 
of investigation, I've come to the conclusion that the code that causes error 
is intentional code to handle a specific case for X (I'll assume X11 until 
corrected):

; diff /sys/src/ape/lib/ap/plan9/_buf.c _buf.c
292a293
> printf("no buffered %d\n", i);
294a296
> /*
298c300
<                               errno = EBADF;          /* how X tells a client 
is gone */
---
>                               errno = EBADF;          // how X tells a client 
> is gone
300a303
> */



By removing the above, Python code that uses subprocess.Popen(cmd, stdout=PIPE, 
stderr=PIPE) will now work correctly, without having to resort to 
os.popen3(cmd) attempts to get around the select.error: (4, 'Bad file number') 
that would crop up without the change.

My question is: does anyone still use the X11 code based on APE?  Is this 
section safe to remove in sources?  Or do you have additional recommendations 
to work around the select() error?

If not, I'll prep a patch.  Thanks.

-jas


Reply via email to