We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3c3e0b3 + a111eb7 commit 144dfc5Copy full SHA for 144dfc5
run-command.c
@@ -67,21 +67,24 @@ static int child_notifier = -1;
67
68
static void notify_parent(void)
69
{
70
- ssize_t unused;
71
- unused = write(child_notifier, "", 1);
+ /*
+ * execvp failed. If possible, we'd like to let start_command
72
+ * know, so failures like ENOENT can be handled right away; but
73
+ * otherwise, finish_command will still report the error.
74
+ */
75
+ xwrite(child_notifier, "", 1);
76
}
77
78
static NORETURN void die_child(const char *err, va_list params)
79
80
char msg[4096];
81
int len = vsnprintf(msg, sizeof(msg), err, params);
82
if (len > sizeof(msg))
83
len = sizeof(msg);
84
- unused = write(child_err, "fatal: ", 7);
- unused = write(child_err, msg, len);
- unused = write(child_err, "\n", 1);
85
+ write_in_full(child_err, "fatal: ", 7);
86
+ write_in_full(child_err, msg, len);
87
+ write_in_full(child_err, "\n", 1);
88
exit(128);
89
90
#endif
t/t0061-run-command.sh
@@ -7,8 +7,31 @@ test_description='Test run command'
7
8
. ./test-lib.sh
9
10
+cat >hello-script <<-EOF
11
+ #!$SHELL_PATH
12
+ cat hello-script
13
+EOF
14
+>empty
15
+
16
test_expect_success 'start_command reports ENOENT' '
17
test-run-command start-command-ENOENT ./does-not-exist
18
'
19
20
+test_expect_success 'run_command can run a command' '
21
+ cat hello-script >hello.sh &&
22
+ chmod +x hello.sh &&
23
+ test-run-command run-command ./hello.sh >actual 2>err &&
24
25
+ test_cmp hello-script actual &&
26
+ test_cmp empty err
27
+'
28
29
+test_expect_success POSIXPERM 'run_command reports EACCES' '
30
31
+ chmod -x hello.sh &&
32
+ test_must_fail test-run-command run-command ./hello.sh 2>err &&
33
34
+ grep "fatal: cannot exec.*hello.sh" err
35
36
37
test_done
test-run-command.c
@@ -29,6 +29,8 @@ int main(int argc, char **argv)
fprintf(stderr, "FAIL %s\n", argv[1]);
return 1;
+ if (!strcmp(argv[1], "run-command"))
+ exit(run_command(&proc));
fprintf(stderr, "check usage\n");
0 commit comments