1 |
commit: c19d16ffe0d00b555b0b5f63da1ae683bca049b0 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jan 20 19:02:17 2014 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 20 19:02:17 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=c19d16ff |
7 |
|
8 |
misc/install.wrapper.c: pass the signal back up the call stack |
9 |
|
10 |
We follow the advice at |
11 |
|
12 |
http://www.cons.org/cracauer/sigint.html |
13 |
|
14 |
and pass the signal back up to the process call stack. |
15 |
|
16 |
--- |
17 |
misc/install.wrapper.c/install.wrapper.c | 23 ++++++++++++++++------- |
18 |
1 file changed, 16 insertions(+), 7 deletions(-) |
19 |
|
20 |
diff --git a/misc/install.wrapper.c/install.wrapper.c b/misc/install.wrapper.c/install.wrapper.c |
21 |
index df2b387..f0425f9 100644 |
22 |
--- a/misc/install.wrapper.c/install.wrapper.c |
23 |
+++ b/misc/install.wrapper.c/install.wrapper.c |
24 |
@@ -2,6 +2,7 @@ |
25 |
* Distributed under the terms of the GNU General Public License v2 |
26 |
* |
27 |
* Copyright 2014 Anthony G. Basile - <blueness@g.o> |
28 |
+ * Copyright 2014 Mike Frysinger - <vapier@g.o> |
29 |
* |
30 |
* Wrapper for coreutil's install to preserve extended attributes. |
31 |
*/ |
32 |
@@ -296,7 +297,6 @@ main(int argc, char* argv[]) |
33 |
|
34 |
default: |
35 |
wait(&status); |
36 |
- status = WEXITSTATUS(status); |
37 |
|
38 |
/* Are there enough files/directories on the cmd line to |
39 |
* proceed? This can happen if install is called with no |
40 |
@@ -304,11 +304,11 @@ main(int argc, char* argv[]) |
41 |
* nothing for the parent to do. |
42 |
*/ |
43 |
if (first >= last) |
44 |
- return status; |
45 |
+ goto done; |
46 |
|
47 |
/* If all the targets are directories, do nothing. */ |
48 |
if (opts_directory) |
49 |
- return status; |
50 |
+ goto done; |
51 |
|
52 |
if (!opts_target_directory) { |
53 |
target = argv[last]; |
54 |
@@ -344,9 +344,18 @@ main(int argc, char* argv[]) |
55 |
} else |
56 |
copyxattr(argv[first], target); |
57 |
|
58 |
- return status; |
59 |
- } |
60 |
|
61 |
- /* We should never get here. */ |
62 |
- return EXIT_FAILURE; |
63 |
+ done: |
64 |
+ /* Do the right thing and pass the signal back up. See: |
65 |
+ * http://www.cons.org/cracauer/sigint.html |
66 |
+ */ |
67 |
+ if (WIFSIGNALED(status)) { |
68 |
+ int signum = WTERMSIG(status); |
69 |
+ kill(getpid(), signum); |
70 |
+ } else if (WIFEXITED(status)) |
71 |
+ return WEXITSTATUS(status); |
72 |
+ else |
73 |
+ return EXIT_FAILURE; /* We should never get here. */ |
74 |
+ |
75 |
+ } |
76 |
} |