Beaker wrote,
>[...]
>Anyways, I've got things working but I'd really like to know what
>the "3" is all about. I read fd(4) which says 3-19 are "user-defined";
>so where is it being defined here ?

Right before the line that invokes gs:

>    exec 3>&1 1>&2

The "3>&1" says, "Whenever anybody writes to descriptor 3, send it to
whatever descriptor 1 (standard output) was pointing to."  The "1>&2"
says, "Whenever anybody writes to descriptor 1 (standard output), send it to
whatever descriptor 2 (standard error) was pointing to."

Thus when gs outputs to /dev/fd/3, it goes to the shell script's standard
output.


For the terminally curious, the redirection is implemented using the
dup2() system call.  The above exec command executes these system calls:

     dup2(1, 3);
     dup2(2, 1);

Read "man dup2" to find out what that means.

               - Neil Parker
_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to