[PATCH 1/2] Fix cg-patch hanging on terminals with TOSTOP flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Pavel Roskin <proski@xxxxxxx>

Terminals with TOSTOP flag don't allow background processes to write to
the terminal.  This flag is used e.g. by the subshell in GNU Midnight
Commander.  It can also be set by "stty tostop".

Redirect stdout and strerr of the "patch" command to a temporary file
and show it once "patch" terminates.

Signed-off-by: Pavel Roskin <proski@xxxxxxx>
---

 cg-patch |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/cg-patch b/cg-patch
index 9ea7de4..115869e 100755
--- a/cg-patch
+++ b/cg-patch
@@ -337,6 +337,7 @@ # parts of the tree from inadverent poll
 [ "$unidiff" ] && newsfile="$(mktemp -t gitapply.XXXXXX)"
 gonefile="$(mktemp -t gitapply.XXXXXX)"
 todo="$(mktemp -t gitapply.XXXXXX)"
+patchout="$(mktemp -t gitapply.XXXXXX)"
 patchfifo="$(mktemp -t gitapply.XXXXXX)"
 rm "$patchfifo" && mkfifo -m 600 "$patchfifo"
 
@@ -347,7 +348,7 @@ # patch file removal behaviour cannot be
 # just handle it all ourselves.
 patch_args="-p$strip -N"
 [ "$reverse" ] && patch_args="$patch_args -R"
-patch $patch_args <"$patchfifo" &
+patch $patch_args <"$patchfifo" >"$patchout" 2>&1 &
 
 tee "$patchfifo" | {
 	redzone_reset
@@ -407,6 +408,7 @@ tee "$patchfifo" | {
 } >$todo
 
 wait %1; ret=$?
+cat "$patchout"
 
 IFS=$'\n' emptyfiles=($(git-ls-files --deleted | join -v 2 "$gonefile" -))
 if [ "$unidiff" ]; then
@@ -441,7 +443,7 @@ while [ "$1" ]; do
 done
 ' padding
 
-rm "$patchfifo" "$todo" "$gonefile"
+rm "$patchfifo" "$todo" "$gonefile" "$patchout"
 [ "$unidiff" ] && rm "$newsfile"
 
 exit $ret

-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]