Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ or placed in a file `~/.callhostrc` (automatically detected and sourced by `call
```
* Using the `ENV()` function in the JDL file may not function as intended, since it will be evaluated on the host node, rather than inside the container with your environment set up.
* Commands that require tty input (such as `nano` or `emacs -nw`) will not work with `call_host`.
* Calling multiple commands at once with `call_host` can break the pipe if the commands are separated by semicolons and a non-final command fails.
The symptom of this will be that subsequent host commands hang, and pressing ctrl+C will give the error message "Interrupted system call".
* Occasionally, if a command fails (especially when calling multiple commands separated by semicolons), the pipe will break and the terminal will appear to hang. The message "Interrupted system call" may be shown.
It is necessary to exit and reenter the container (in order to create a new pipe) if this occurs.
To avoid this, chain multiple commands using logical operators (`&&` or `||`), or surround all the commands in `()` (thereby running them in a subshell).
* Stopping a command in progress with ctrl+C will also break the pipe (as described in the previous item).
To prevent this, chain multiple commands using logical operators (`&&` or `||`), or surround all the commands in `()` (thereby running them in a subshell).
* Stopping a command in progress with ctrl+C is disabled (to avoid breaking the pipe as described in the previous item).
* Suspending a command with ctrl+Z is not supported and may break the session.

## `bind_condor.sh`

Expand Down
13 changes: 9 additions & 4 deletions call_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# check for configuration
CALL_HOST_CONFIG=~/.callhostrc
if [ -f "$CALL_HOST_CONFIG" ]; then
# shellcheck source=/dev/null
# shellcheck source=/dev/null
source "$CALL_HOST_CONFIG"
fi

Expand Down Expand Up @@ -58,11 +58,14 @@ export -f call_host_disable
listenhost(){
# stop when host pipe is removed
while [ -e "$1" ]; do
# "|| true" is necessary to stop "Interrupted system call"
# must be *inside* eval to ensure EOF once command finishes
# "|| true" is necessary to stop "Interrupted system call" when running commands like 'command1; command2; command3'
# now replaced with assignment of exit code to local variable (which also returns true)
# using { bash -c ... } >& is less fragile than eval
tmpexit=0
eval "$(cat "$1") || tmpexit="'$?' >& "$2"
cmd="$(cat "$1")"
{
bash -c "$cmd" || tmpexit=$?
} >& "$2"
echo "$tmpexit" > "$3"
done
}
Expand All @@ -89,6 +92,8 @@ export -f startpipe

# sends function to host, then listens for output, and provides exit code from function
call_host(){
# disable ctrl+c to prevent "Interrupted system call"
trap "" SIGINT
if [ "${FUNCNAME[0]}" = "call_host" ]; then
FUNCTMP=
else
Expand Down