Created
October 22, 2014 06:23
-
-
Save kuy/eddc371d50b7a9525218 to your computer and use it in GitHub Desktop.
Learning Named Pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
root=$(cd $(dirname $0); pwd) | |
pipe="/tmp/np-$$" | |
mkfifo $pipe | |
echo "np-main: pipe created: $pipe" | |
"$root/np-sub.sh" "$pipe" "$@" & | |
echo "np-main: from sub: $(cat $pipe)" | |
echo "np-main: exit code: $?" | |
rm -f $pipe | |
echo "np-main: pipe deleted" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [[ ! -z $2 ]]; then | |
echo "" >$1 | |
echo "np-sub: error" >&2 | |
exit 1 | |
fi | |
echo "np-sub: named pipe!" >$1 | |
echo "np-sub: success" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment