9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Jeff Sickel <jas@corpus-callosum.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] APE select() and awkward Python subprocess PIPEfitting
Date: Mon, 25 Feb 2013 20:29:43 -0600	[thread overview]
Message-ID: <0BE4B21D-EDA9-4DF5-8515-7BA27841B3E3@corpus-callosum.com> (raw)

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	other threads:[~2013-02-26  2:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26  2:29 Jeff Sickel [this message]
2013-02-26  5:53 ` Jeff Sickel
2013-02-26 11:25 ` Yaroslav
2013-02-26 11:41   ` Charles Forsyth
2013-02-26 16:17     ` Jeff Sickel
2013-02-26 15:29   ` Jeff Sickel
2013-02-26 16:20     ` Charles Forsyth
2013-02-26 16:26       ` Charles Forsyth
2013-02-26 17:01         ` Jeff Sickel
2013-02-26 18:36           ` Charles Forsyth
2013-02-26 16:48     ` Anthony Sorace
2013-02-26 18:25       ` Jeff Sickel
2013-02-27  2:03     ` Federico G. Benavento
2013-02-27 15:03       ` Jeff Sickel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0BE4B21D-EDA9-4DF5-8515-7BA27841B3E3@corpus-callosum.com \
    --to=jas@corpus-callosum.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).