Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
300ad972
...
300ad97282e391993e74cab85e44f063bae492de
authored
2005-03-18 14:35:18 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(mail_execute): Restore argv[0] before exiting, else argcv_free coredumps.
1 parent
9ecdeda7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
mail/shell.c
mail/shell.c
View file @
300ad97
...
...
@@ -62,10 +62,16 @@ mail_execute (int shell, int argc, char **argv)
{
pid_t
pid
;
char
*
buf
=
NULL
;
char
*
argv0
=
NULL
;
if
(
argc
)
{
argv0
=
argv
[
0
];
/* Skip leading whitespace from argv[0] */
while
(
isspace
(
**
argv
))
(
*
argv
)
++
;
}
/* Expand arguments if required */
if
(
util_getenv
(
NULL
,
"bang"
,
Mail_env_boolean
,
0
)
==
0
)
...
...
@@ -77,7 +83,7 @@ mail_execute (int shell, int argc, char **argv)
}
/* Construct command line and save it to gnu-last-command variable */
argcv_string
(
argc
,
&
argv
[
0
]
,
&
buf
);
argcv_string
(
argc
,
argv
,
&
buf
);
util_setenv
(
"gnu-last-command"
,
buf
,
Mail_env_string
,
1
);
/* Do actual work */
...
...
@@ -111,19 +117,23 @@ mail_execute (int shell, int argc, char **argv)
execvp
(
argv
[
0
],
argv
);
exit
(
1
);
}
else
if
(
pid
>
0
)
else
{
if
(
argv0
)
/* Restore argv[0], else argcv_free will coredump */
argv
[
0
]
=
argv0
;
free
(
buf
);
if
(
pid
>
0
)
{
while
(
waitpid
(
pid
,
NULL
,
0
)
==
-
1
)
/* do nothing */
;
return
0
;
}
else
if
(
pid
<
0
)
else
/* if (pid < 0) */
{
free
(
buf
);
mu_error
(
"fork failed: %s"
,
mu_strerror
(
errno
));
return
1
;
}
}
}
/*
...
...
Please
register
or
sign in
to post a comment