bug-apl
[Top][All Lists]
Advanced

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

Re: ⎕FIO non Zero Return Code related to ⎕FX


From: Dr . Jürgen Sauermann
Subject: Re: ⎕FIO non Zero Return Code related to ⎕FX
Date: Fri, 30 Oct 2020 14:20:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hi Hans-Peter,

I have checked the ⎕FIO code and it looks correct to me.

In your first example I get the result that you are expecting:

*      Command←'echo "sad x asds" | sed "s/x/y/g"'**
**      Handle←⎕FIO[24] Command**
**      D←⎕FIO[6] Handle**
**      ZN←⎕UCS D**
**      ZN **
**sad y asds**
**
****
**      ⎕FIO[25] Handle**
**0*

Having that said, consider this:

The error code *-10* means *ECHILD*:

*eedjsa@server68:~/projects/juergen/apl-1.8/src$ errno ECHILD**
**ECHILD 10 No child processes**
*
According to *man pclose*:

       If pclose() cannot obtain the child status, errno is set to ECHILD.

I suppose this is what happens here. For some reasons (beyond what GNU APL can do) either your shell or your operating system is unable to determine the exit status of your process (i.e. of the Command that you are executing). Maybe this is related to using a pipe, but maybe not.

Please keep in mind that the shell which popen() aka. ⎕FIO[24] uses could be different different then the shell from the shell that has started apl. In my case the shell that has started apl was *bash* while popen uses *sh*. For that reason I get a syntax error with you  second example (*sh* does not know <<<) while you don't. That also points to shell
differences.

A work-around for this problem might be to return an explicit exit code from your command:

*      Command←'echo "sad x asds" | sed "s/x/y/g" && exit 3'**
**      ⎕UCS (⎕FIO[6] Handle←⎕FIO[24] Command) ◊ ⎕FIO[25] Handle**
**sad y asds**
**
**768**
*
The *728* above is the exit code *3* shifted 8 bits. This is only to demonstrate the shift,
normally you would use 0 instead of 3.

Hope this helps,
Jürgen


On 10/29/20 9:06 PM, Hans-Peter Sorge wrote:
Hi,

the Command is being correctly executed, the return codes are -10

      Command←'echo "sad x asds" | sed "s/x/y/g"'
      Handle←⎕FIO[24] Command
      D←⎕FIO[6] Handle
      ZN←⎕UCS D
      ZN
sad y asds

      ⎕FIO[25] Handle
¯10

      Command←'sed "s/x/y/g" <<< "sad x asds"'
      Handle←⎕FIO[24] Command
       D←⎕FIO[6] Handle
      ZN←⎕UCS D
      ZN
sad y asds

      ⎕FIO[25] Handle
¯10


However starting a new apl session gives:

      Command←'sed "s/x/y/g" <<< "sad x asds"'
      Handle←⎕FIO[24] Command
      D←⎕FIO[6] Handle
      ZN←⎕UCS D
      ⎕FIO[25] Handle
0

      'libedif2.so' ⎕FX 'E'
E

      Command←'sed "s/x/y/g" <<< "sad x asds"'
      Handle←⎕FIO[24] Command
      D←⎕FIO[6] Handle
      ZN←⎕UCS D
      ⎕FIO[25] Handle
¯10

I have not checked other native functions.

Regards
Hans-Peter






reply via email to

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