help-bash
[Top][All Lists]
Advanced

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

Re: why did coprocs fd not exist, in this sample submissed on an issue a


From: Alex fxmbsw7 Ratchev
Subject: Re: why did coprocs fd not exist, in this sample submissed on an issue as answer
Date: Thu, 30 Sep 2021 21:49:52 +0200

i think the middle chapter is the because, sorry i understand your english
only modestly
in this case of code i can easily aviod coproc then
thanks you

On Thu, Sep 30, 2021, 21:31 Chet Ramey <chet.ramey@case.edu> wrote:

> On 9/30/21 12:55 PM, Alex fxmbsw7 Ratchev wrote:
> > s=ab34 ; awksplit() { gawk -v FS= -v RS=\\0 -v ORS=\\0 -e '{ gsub( /./,
> > "\\\\& " ) ; print }' "$@" ; } ; declare -a "one=( $( awksplit <<<"$s" -v
> > ORS= ) )" ; declare -p one  ; [[ ! -v ser ]] && coproc ser { awksplit ;
> } ;
> > ser() { printf %s\\0 "${@:2}" >&${ser[1]} ; declare -ga "$1=( $( <
> > /proc/fd/$ser ) )" ; declare -p $1 ; } ; ser serial "$s"
> >
> > declare -a one=([0]="a" [1]="b" [2]="3" [3]="4")
> > [1] 17511
> > bash: /proc/fd/57: No such file or directory
> > declare -a serial=()
> >
> > besides the [[ -v ser doesnt work, i suspect ser[0] may
>
> coproc file descriptors are close-on-exec, plus the shell takes care to
> close them when creating subshells. Stray file descriptors open to pipes
> can cause deadlocks or prevent EOF delivery.
>
> "The file descriptors
> can  be  utilized as arguments to shell commands and redirections using
> standard word expansions.  Other than those created to execute  command
> and  process  substitutions,  the file descriptors are not available in
> subshells."
>
> If you want a file descriptor that's not close-on-exec, use redirection
> to copy it. But then you have to manage closing them yourself when it's
> necessary.
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]