Lines 1-57
Link Here
|
1 |
--- ./tools/common.c.orig 2010-03-31 03:28:20.000000000 +0200 |
|
|
2 |
+++ ./tools/common.c 2010-06-01 13:26:57.576932723 +0200 |
3 |
@@ -58,7 +58,9 @@ |
4 |
#include <unistd.h> |
5 |
#include <fcntl.h> |
6 |
#include <errno.h> |
7 |
+#ifdef HAVE_SPAWN_H |
8 |
#include <spawn.h> |
9 |
+#endif |
10 |
#include <sys/wait.h> |
11 |
|
12 |
#include <popt.h> |
13 |
@@ -327,6 +329,7 @@ |
14 |
} |
15 |
} |
16 |
|
17 |
+#ifdef HAVE_SPAWN_H |
18 |
void pipeline(const char * const *argv, struct pipeline *pl) |
19 |
{ |
20 |
posix_spawn_file_actions_t file_acts; |
21 |
@@ -356,6 +359,36 @@ |
22 |
|
23 |
pl->infd = pipefds[1]; |
24 |
} |
25 |
+#else |
26 |
+void pipeline(const char * const *argv, struct pipeline *pl) |
27 |
+{ |
28 |
+ int pipefds[2]; |
29 |
+ if (pipe(pipefds)) |
30 |
+ die_errno(errno, "pipe"); |
31 |
+ |
32 |
+ pl->pid = fork(); |
33 |
+ |
34 |
+ if (pl->pid == -1) |
35 |
+ die_errno(errno, "fork: %s", argv[0]); |
36 |
+ else |
37 |
+ if (pl->pid == 0) { |
38 |
+ if (dup2(pipefds[0], 0)) |
39 |
+ die_errno(errno, "dup2()"); |
40 |
+ if (close(pipefds[0])) |
41 |
+ die_errno(errno, "close()"); |
42 |
+ if (close(pipefds[1])) |
43 |
+ die_errno(errno, "close()"); |
44 |
+ execvp(argv[0], argv); |
45 |
+ die_errno(errno, "execvp()"); |
46 |
+ } |
47 |
+ else { |
48 |
+ if (close(pipefds[0])) |
49 |
+ die_errno(errno, "close"); |
50 |
+ } |
51 |
+ |
52 |
+ pl->infd = pipefds[1]; |
53 |
+} |
54 |
+#endif |
55 |
|
56 |
int finish_pipeline(struct pipeline *pl) |
57 |
{ |