Browse Source
Previously, failures during execvp could be detected only by finish_command. However, in some situations it is beneficial for the parent process to know earlier that the child process will not run. The idea to use a pipe to signal failures to the parent process and the test case were lifted from patches by Ilari Liusvaara. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
Johannes Sixt
15 years ago
committed by
Junio C Hamano
4 changed files with 96 additions and 1 deletions
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh |
||||
# |
||||
# Copyright (c) 2009 Ilari Liusvaara |
||||
# |
||||
|
||||
test_description='Test run command' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
test_expect_success 'start_command reports ENOENT' ' |
||||
test-run-command start-command-ENOENT ./does-not-exist |
||||
' |
||||
|
||||
test_done |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
/* |
||||
* test-run-command.c: test run command API. |
||||
* |
||||
* (C) 2009 Ilari Liusvaara <ilari.liusvaara@elisanet.fi> |
||||
* |
||||
* This code is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License version 2 as |
||||
* published by the Free Software Foundation. |
||||
*/ |
||||
|
||||
#include "git-compat-util.h" |
||||
#include "run-command.h" |
||||
#include <string.h> |
||||
#include <errno.h> |
||||
|
||||
int main(int argc, char **argv) |
||||
{ |
||||
struct child_process proc; |
||||
|
||||
memset(&proc, 0, sizeof(proc)); |
||||
|
||||
if (argc < 3) |
||||
return 1; |
||||
proc.argv = (const char **)argv+2; |
||||
|
||||
if (!strcmp(argv[1], "start-command-ENOENT")) { |
||||
if (start_command(&proc) < 0 && errno == ENOENT) |
||||
return 0; |
||||
fprintf(stderr, "FAIL %s\n", argv[1]); |
||||
return 1; |
||||
} |
||||
|
||||
fprintf(stderr, "check usage\n"); |
||||
return 1; |
||||
} |
Loading…
Reference in new issue