Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
0b6bb37c
Commit
0b6bb37c
authored
6 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: improve some comments, and exit with nonzero status upon error
parent
c43a6fdc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/text.c
+12
-8
src/text.c
with
12 additions
and
8 deletions
+12
-8
src/text.c
View file @
0b6bb37c
...
...
@@ -1090,35 +1090,39 @@ bool execute_command(const char *command)
bool
setup_failed
=
FALSE
;
/* Whether setting up the temporary SIGINT handler failed. */
/*
Make our pipes
. */
/*
Create a pipe to read the command's output from
. */
if
(
pipe
(
fd
)
==
-
1
)
{
statusbar
(
_
(
"Could not create pipe"
));
return
FALSE
;
}
/* Check $SHELL for the shell to use. If it isn't set, use /bin/sh.
* Note that $SHELL should contain only a path, with no arguments. */
/* Check which shell to use. If none is specified, use /bin/sh. */
shellenv
=
getenv
(
"SHELL"
);
if
(
shellenv
==
NULL
)
shellenv
=
(
char
*
)
"/bin/sh"
;
/* Fork a child. */
/* Fork a child
process to run the command in
. */
if
((
pid
=
fork
())
==
0
)
{
/* Child: close the unused read end of the pipe. */
close
(
fd
[
0
]);
/* Connect the write end of the pipe to the process' output streams. */
dup2
(
fd
[
1
],
fileno
(
stdout
));
dup2
(
fd
[
1
],
fileno
(
stderr
));
/*
If execl() returns at all, there was an error
. */
/*
Run the given command inside the preferred shell
. */
execl
(
shellenv
,
tail
(
shellenv
),
"-c"
,
command
,
NULL
);
exit
(
0
);
/* If the exec call returns, there was an error. */
exit
(
1
);
}
/*
Continue as parent
. */
/*
Parent: close the unused write end of the pipe
. */
close
(
fd
[
1
]);
if
(
pid
==
-
1
)
{
close
(
fd
[
0
]);
statusbar
(
_
(
"Could not fork"
));
close
(
fd
[
0
]);
return
FALSE
;
}
...
...
This diff is collapsed.
Click to expand it.
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