aboutsummaryrefslogtreecommitdiffhomepage
path: root/exec.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2007-01-08 00:09:18 +1000
committerGravatar axel <axel@liljencrantz.se>2007-01-08 00:09:18 +1000
commit2fcec27e238a90021d890ad1a4ed2d69383f9e73 (patch)
treeaaeeb5aece7241211df31792fb86003ef507af17 /exec.c
parent42d02834892c7c7ac165d46c08d55ecfe9e8b643 (diff)
Make sure errno is not changed when error reporting after a failed call to execve
darcs-hash:20070107140918-ac50b-35186f2300d6ec03dbeac2cb5d5ffcee3feffc4e.gz
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/exec.c b/exec.c
index 2388d965..e5628a80 100644
--- a/exec.c
+++ b/exec.c
@@ -450,13 +450,16 @@ static int setup_child_process( job_t *j, process_t *p )
static void launch_process( process_t *p )
{
FILE* f;
-
+ int err;
+
// debug( 1, L"exec '%ls'", p->argv[0] );
execve ( wcs2str(p->actual_cmd),
wcsv2strv( (const wchar_t **) p->argv),
env_export_arr( 0 ) );
-
+
+ err = errno;
+
/*
Something went wrong with execve, check for a ":", and run
/bin/sh if encountered. This is a weird predecessor to the shebang
@@ -475,8 +478,7 @@ static void launch_process( process_t *p )
{
int count = 0;
int i = 1;
- int j = 2;
- wchar_t **res;
+ wchar_t **res;
while( p->argv[count] != 0 )
count++;
@@ -503,6 +505,9 @@ static void launch_process( process_t *p )
debug( 0,
_( L"Failed to execute process '%ls'" ),
p->actual_cmd );
+
+ errno = err;
+
wperror( L"execve" );
exit(1);
}