Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
698861dc
Commit
698861dc
authored
Dec 08, 2009
by
Doug Evans
Committed by
Doug Evans
Dec 08, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* pex-unix.c (pex_unix_exec_child): Save/restore environ.
From-SVN: r155079
parent
d16a31da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletions
+24
-1
libiberty/ChangeLog
+4
-0
libiberty/pex-unix.c
+20
-1
No files found.
libiberty/ChangeLog
View file @
698861dc
2009-12-07 Doug Evans <dje@google.com>
* pex-unix.c (pex_unix_exec_child): Save/restore environ.
2009-11-26 Ben Elliston <bje@au.ibm.com>
2009-11-26 Ben Elliston <bje@au.ibm.com>
* configure.ac (AC_CHECK_FUNCS): Sort into alphabetic order.
* configure.ac (AC_CHECK_FUNCS): Sort into alphabetic order.
...
...
libiberty/pex-unix.c
View file @
698861dc
...
@@ -400,6 +400,12 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
...
@@ -400,6 +400,12 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
volatile
int
sleep_interval
;
volatile
int
sleep_interval
;
volatile
int
retries
;
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.
It would be nice to use one of the exec* functions that takes an
environment as a parameter, but that may have portability issues. */
char
**
save_environ
=
environ
;
sleep_interval
=
1
;
sleep_interval
=
1
;
pid
=
-
1
;
pid
=
-
1
;
for
(
retries
=
0
;
retries
<
4
;
++
retries
)
for
(
retries
=
0
;
retries
<
4
;
++
retries
)
...
@@ -453,7 +459,12 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
...
@@ -453,7 +459,12 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
}
}
if
(
env
)
if
(
env
)
environ
=
(
char
**
)
env
;
{
/* NOTE: In a standard vfork implementation this clobbers the
parent's copy of environ "too" (in reality there's only one copy).
This is ok as we restore it below. */
environ
=
(
char
**
)
env
;
}
if
((
flags
&
PEX_SEARCH
)
!=
0
)
if
((
flags
&
PEX_SEARCH
)
!=
0
)
{
{
...
@@ -471,6 +482,14 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
...
@@ -471,6 +482,14 @@ pex_unix_exec_child (struct pex_obj *obj, int flags, const char *executable,
default:
default:
/* Parent process. */
/* Parent process. */
/* Restore environ.
Note that the parent either doesn't run until the child execs/exits
(standard vfork behaviour), or if it does run then vfork is behaving
more like fork. In either case we needn't worry about clobbering
the child's copy of environ. */
environ
=
save_environ
;
if
(
in
!=
STDIN_FILE_NO
)
if
(
in
!=
STDIN_FILE_NO
)
{
{
if
(
close
(
in
)
<
0
)
if
(
close
(
in
)
<
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment