From: dje@google.com (Doug Evans)
To: gcc-patches@gcc.gnu.org
Cc: gdb-patches@sourceware.org
Subject: [RFA] save/restore environ in libiberty pex_unix_exec_child
Date: Mon, 07 Dec 2009 17:26:00 -0000 [thread overview]
Message-ID: <20091207172641.398198456F@ruffy.mtv.corp.google.com> (raw)
Hi.
I ran into this while using pex_run_in_environment in gdb.
Ok to check in?
2009-12-07 Doug Evans <dje@google.com>
* pex-unix.c (pex_unix_exec_child): Save/restore environ.
==== //depot2/gcctools/google_vendor_src_branch/gdb/gdb-7.0.x-prod/libiberty/pex-unix.c#1 - /usr/local/google/home/dje/ctools/gdb/7.0.x-prod/depot2/gcctools/google_vendor_src_branch/gdb/gdb-7.0.x-prod/libiberty/pex-unix.c ====
--- /tmp/g4-67641/cache/depot2/gcctools/google_vendor_src_branch/gdb/gdb-7.0.x-prod/libiberty/pex-unix.c#1 2009-12-06 12:30:36.000000000 -0800
+++ /usr/local/google/home/dje/ctools/gdb/7.0.x-prod/depot2/gcctools/google_vendor_src_branch/gdb/gdb-7.0.x-prod/libiberty/pex-unix.c 2009-12-06 12:27:46.000000000 -0800
@@ -397,6 +397,10 @@
volatile int sleep_interval;
volatile int retries;
+ /* We vfork and then set environ in the child before calling execvp.
+ This clobbers the parent's environ so we need to restore it. */
+ char **save_environ = environ;
+
sleep_interval = 1;
pid = -1;
for (retries = 0; retries < 4; ++retries)
@@ -468,6 +472,7 @@
default:
/* Parent process. */
+ environ = save_environ;
if (in != STDIN_FILE_NO)
{
if (close (in) < 0)
next reply other threads:[~2009-12-07 17:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-07 17:26 Doug Evans [this message]
2009-12-07 20:10 ` DJ Delorie
2009-12-07 20:25 ` Doug Evans
2009-12-07 20:55 ` DJ Delorie
2009-12-07 21:37 ` Doug Evans
[not found] ` <200912072009.nB7K9moj000406__858.220636337315$1260216617$gmane$org@greed.delorie.com>
2009-12-07 20:28 ` Tom Tromey
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=20091207172641.398198456F@ruffy.mtv.corp.google.com \
--to=dje@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gdb-patches@sourceware.org \
/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