Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] save/restore environ in libiberty pex_unix_exec_child
@ 2009-12-07 17:26 Doug Evans
  2009-12-07 20:10 ` DJ Delorie
       [not found] ` <200912072009.nB7K9moj000406__858.220636337315$1260216617$gmane$org@greed.delorie.com>
  0 siblings, 2 replies; 6+ messages in thread
From: Doug Evans @ 2009-12-07 17:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: gdb-patches

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)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-07 21:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-07 17:26 [RFA] save/restore environ in libiberty pex_unix_exec_child Doug Evans
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox