git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
PRPavel Roskin <proski@gnu.org>
Date
May 25, 2006, 01:40 UTC
Message-ID
<20060525014001.27814.23082.stgit@dv.roinet.com>
From: Pavel Roskin <proski@gnu.org>

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@gnu.org>
---
 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
Next: Pavel Roskin
Message 1 of 2 in “Fix cg-patch hanging on terminals with TOSTOP flag”
  1. 1/2 Fix cg-patch hanging on terminals with TOSTOP flagPavel Roskin, May 25, 2006
  2. 2/2 Improve the tutorial scriptPavel Roskin, May 25, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.