[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to not terminate a process using pipe?
From: |
Peng Yu |
Subject: |
Re: [Help-bash] How to not terminate a process using pipe? |
Date: |
Wed, 21 Feb 2018 17:07:31 -0600 |
> The echo will open and close the the file refered to by in and out.
> The close action will cause cat to quit.
>
> What you need to do is to keep the files open, like
>
> mkfifo in out
> exec 111<in 222>out
>
> echo x >&111
> read -r x <&222
>
> echo x >&111
> read -r x <&222
>
> # Close the file descriptors.
> exec 111<&- 222<&-
This does not seem to work as it hangs there.
/tmp$ cat main1.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
tmpdir=$(mktemp -d)
mkfifo "$tmpdir"/infifo "$tmpdir"/outfifo
set -v
exec 111<"$tmpdir"/infifo 222>"$tmpdir"/outfifo
echo x >&111
read -r x <&222
echo x >&111
read -r x <&222
# Close the file descriptors.
exec 111<&- 222<&-
/tmp$ ./main1.sh
exec 111<"$tmpdir"/infifo 222>"$tmpdir"/outfifo
--
Regards,
Peng