mirror of
https://salsa.debian.org/srivasta/make-dfsg.git
synced 2024-12-25 13:41:45 +00:00
Formerly function.c.~28~
This commit is contained in:
parent
f7f63b75b5
commit
ca3b88c66a
1 changed files with 23 additions and 8 deletions
31
function.c
31
function.c
|
@ -324,7 +324,7 @@ expand_function (o, function, text, end)
|
||||||
|
|
||||||
case function_shell:
|
case function_shell:
|
||||||
{
|
{
|
||||||
char **argv;
|
char **argv, **envp;
|
||||||
char *error_prefix;
|
char *error_prefix;
|
||||||
int pipedes[2];
|
int pipedes[2];
|
||||||
int pid;
|
int pid;
|
||||||
|
@ -337,6 +337,9 @@ expand_function (o, function, text, end)
|
||||||
if (argv == 0)
|
if (argv == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Construct the environment. */
|
||||||
|
envp = target_environment ((struct file *) 0);
|
||||||
|
|
||||||
/* For error messages. */
|
/* For error messages. */
|
||||||
if (reading_filename != 0)
|
if (reading_filename != 0)
|
||||||
{
|
{
|
||||||
|
@ -357,18 +360,32 @@ expand_function (o, function, text, end)
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
perror_with_name (error_prefix, "fork");
|
perror_with_name (error_prefix, "fork");
|
||||||
else if (pid == 0)
|
else if (pid == 0)
|
||||||
child_execute_job (0, pipedes[1], argv, environ);
|
child_execute_job (0, pipedes[1], argv, envp);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* We are the parent. Set up and read from the pipe. */
|
/* We are the parent. */
|
||||||
char *buffer = (char *) xmalloc (201);
|
|
||||||
unsigned int maxlen = 200;
|
char *buffer;
|
||||||
|
unsigned int maxlen;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
/* Record the PID for child_handler. */
|
/* Free the storage only the child needed. */
|
||||||
|
free (argv[0]);
|
||||||
|
free ((char *) argv);
|
||||||
|
for (i = 0; envp[i] != 0; ++i)
|
||||||
|
free (envp[i]);
|
||||||
|
free ((char *) envp);
|
||||||
|
|
||||||
|
/* Record the PID for reap_children. */
|
||||||
shell_function_pid = pid;
|
shell_function_pid = pid;
|
||||||
shell_function_completed = 0;
|
shell_function_completed = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* Set up and read from the pipe. */
|
||||||
|
|
||||||
|
maxlen = 200;
|
||||||
|
buffer = (char *) xmalloc (maxlen + 1);
|
||||||
|
|
||||||
/* Close the write side of the pipe. */
|
/* Close the write side of the pipe. */
|
||||||
(void) close (pipedes[1]);
|
(void) close (pipedes[1]);
|
||||||
|
|
||||||
|
@ -433,8 +450,6 @@ expand_function (o, function, text, end)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free (argv[0]);
|
|
||||||
free ((char *) argv);
|
|
||||||
free (buffer);
|
free (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue