From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Joshua Lock <joshua.g.lock@linux.intel.com>,
bitbake-devel@lists.openembedded.org
Subject: Re: [PATCH v2] prserv/serv: Tweak stdout manipulation to be stream safe
Date: Thu, 05 Jan 2017 14:54:07 +0000 [thread overview]
Message-ID: <1483628047.4367.92.camel@linuxfoundation.org> (raw)
In-Reply-To: <1483627614.7913.1.camel@linux.intel.com>
On Thu, 2017-01-05 at 14:46 +0000, Joshua Lock wrote:
> On Thu, 2017-01-05 at 13:52 +0000, Richard Purdie wrote:
> > + # to physically close the fds to prevent the program
> > launching us from
> > + # potentially hanging on a pipe. Handle both cases.
> > si = open('/dev/null', 'r')
> > + try:
> > + os.dup2(si.fileno(),sys.stdin.fileno())
> > + except (AttributeError, io.UnsupportedOperation):
> > + sys.stdin = si
> > so = open(self.logfile, 'a+')
> > - se = so
> > - os.dup2(si.fileno(),sys.stdin.fileno())
> > - os.dup2(so.fileno(),sys.stdout.fileno())
> > - os.dup2(se.fileno(),sys.stderr.fileno())
> > + try:
> > + os.dup2(so.fileno(),sys.stdout.fileno())
> > + except (AttributeError, io.UnsupportedOperation):
> > + sys.stdout = so
> > + try:
> > + os.dup2(so.fileno(),sys.stderr.fileno())
> > + except (AttributeError, io.UnsupportedOperation):
> > + sys.stderr = so
> I think there's a copy/paste error here — shouldn't the second
> try/except be duplicating/assigning se not so?
so == se in the original code and I dropped that just using so
everywhere here so I believe the code is ok.
Cheers,
Richard
prev parent reply other threads:[~2017-01-05 14:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 13:52 [PATCH v2] prserv/serv: Tweak stdout manipulation to be stream safe Richard Purdie
2017-01-05 14:46 ` Joshua Lock
2017-01-05 14:54 ` Richard Purdie [this message]
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=1483628047.4367.92.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=bitbake-devel@lists.openembedded.org \
--cc=joshua.g.lock@linux.intel.com \
/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