1 |
This allows us to spawn 'tee' as separate process while keeping |
2 |
the function code executed in the main shell. |
3 |
--- |
4 |
gx86/eclass/multibuild.eclass | 19 ++++++++++--------- |
5 |
1 file changed, 10 insertions(+), 9 deletions(-) |
6 |
|
7 |
diff --git a/gx86/eclass/multibuild.eclass b/gx86/eclass/multibuild.eclass |
8 |
index 716d34f..d42b8a7 100644 |
9 |
--- a/gx86/eclass/multibuild.eclass |
10 |
+++ b/gx86/eclass/multibuild.eclass |
11 |
@@ -108,18 +108,20 @@ multibuild_foreach() { |
12 |
local MULTIBUILD_VARIANT=${v} |
13 |
local MULTIBUILD_ID=${prev_id}${v} |
14 |
local BUILD_DIR=${bdir%%/}-${v} |
15 |
+ local log_fd |
16 |
|
17 |
- einfo "${v}: running ${@}" \ |
18 |
- | tee -a "${T}/build-${MULTIBUILD_ID}.log" |
19 |
+ # redirect_alloc_fd accepts files only. so we need to open |
20 |
+ # a random file and then reuse the fd for logger process. |
21 |
+ redirect_alloc_fd log_fd /dev/null |
22 |
+ eval "exec ${log_fd}> "'>(exec tee -a "${T}/build-${MULTIBUILD_ID}.log")' |
23 |
+ |
24 |
+ eval 'einfo "${v}: running ${@}" >&'${log_fd}' 2>&1' |
25 |
|
26 |
# _multibuild_parallel() does redirection internally. |
27 |
# this is a hidden API to avoid writing multilib_foreach twice. |
28 |
- if [[ ${1} == _multibuild_parallel ]]; then |
29 |
- "${@}" |
30 |
- else |
31 |
- "${@}" 2>&1 | tee -a "${T}/build-${MULTIBUILD_ID}.log" |
32 |
- fi |
33 |
+ eval '"${@}" >&'${log_fd}' 2>&1' |
34 |
lret=${?} |
35 |
+ eval "exec ${log_fd}>&-" |
36 |
done |
37 |
[[ ${ret} -eq 0 && ${lret} -ne 0 ]] && ret=${lret} |
38 |
|
39 |
@@ -145,8 +147,7 @@ multibuild_parallel_foreach() { |
40 |
_multibuild_parallel() { |
41 |
( |
42 |
multijob_child_init |
43 |
- "${@}" 2>&1 | tee -a "${T}/build-${MULTIBUILD_ID}.log" |
44 |
- exit ${PIPESTATUS[0]} |
45 |
+ "${@}" |
46 |
) & |
47 |
multijob_post_fork |
48 |
} |
49 |
-- |
50 |
1.8.1.4 |