• Algol 68 / Genie - exiting: action failed, sigpipe_handler

    From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.misc on Tue Sep 16 16:39:19 2025
    From Newsgroup: comp.lang.misc

    Picking just an initial sequence of the created output lines issues an
    error diagnostic:

    $ genie -x 'FOR i TO 2000 DO print ((i, newline)) OD' | head -2
    +1
    +2
    a68g: exiting: action failed (a68g-bits.c: 196, sigpipe_handler)

    And defining event handler (say, 'on transput error' or 'on file end')
    in the Genie Algol 68 source doesn't catch that diagnostic, it seems?

    Usually I'm annoyed by such diagnostics in application cases like the
    pipe constructs on OS/shell level.


    Compared to using other Unix processes as data source, with no error:

    $ yes | head -2
    y
    y

    $ seq 2000000 | head -2
    1
    2

    $ awk 'BEGIN {while(1) print c++}' | head -2
    0
    1

    $ curl -# algol68.gridbug.de/algol68.vim | head -2
    " Vim syntax file
    " Language: Algol 68


    On the other hand (with some of above processes in a pipe-sequence):

    $ yes | awk '{print c++}' | head -2
    0
    1
    yes: standard output: Connection reset by peer
    yes: write error


    I wondered whether it makes sense to have the diagnostics. So I added
    actions (with side effects) after the output statements (in the Algol
    sample and in the first Awk sample above), namely printing a message
    on the error channel; the messages didn't appear, i.e. the programs
    got aborted (of course) because they couldn't finish their preceding (output-)operations.

    Should there be a diagnostic message or not, should such diagnostic
    be interceptable by an event handler or not?

    What's the rationale for Awk not printing a diagnostic message, but
    Genie/Algol 68 does?

    Janis

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From richard@richard@cogsci.ed.ac.uk (Richard Tobin) to comp.lang.misc on Tue Sep 16 18:55:54 2025
    From Newsgroup: comp.lang.misc

    In article <10absqn$2kub3$1@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

    What's the rationale for Awk not printing a diagnostic message, but >Genie/Algol 68 does?

    The default unix behaviour is for a process to simply exit without
    printing any message when it receives a SIGPIPE, which is exactly what
    you want for the kind of pipelines you showed.

    In my view that's the correct default behaviour. The receiving end of
    a pipe closing is normal behaviour, not an error - unlike, say, being
    unable to write a file because the disk is full.

    You can imagine cases where this isn't what you want, so it's
    reasonable for a language to provide a way for a program to set the
    SIGPIPE handler or for it to intercept SIGPIPE itself and expose it as
    an exception (as Python does). Intercepting it, printing an error
    message, and exiting does not seem useful.

    -- Richard
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Andy Walker@anw@cuboid.co.uk to comp.lang.misc on Wed Sep 17 17:39:09 2025
    From Newsgroup: comp.lang.misc

    On 16/09/2025 15:39, Janis Papanagnou wrote:
    Picking just an initial sequence of the created output lines issues an
    error diagnostic:
    $ genie -x 'FOR i TO 2000 DO print ((i, newline)) OD' | head -2
    +1
    +2
    a68g: exiting: action failed (a68g-bits.c: 196, sigpipe_handler)
    And defining event handler (say, 'on transput error' or 'on file end')
    in the Genie Algol 68 source doesn't catch that diagnostic, it seems?

    Indeed; there is no error in the A68G.

    Usually I'm annoyed by such diagnostics in application cases like the
    pipe constructs on OS/shell level.

    I think the root problem is that there are too many ways a pipe
    can fail, some of which are expected and some not, so that "SIGPIPE" is
    being expected to guess whether there has been an error. I agree with
    Richard [nearby article] that the Unix/Linux default is to fail silently,
    and that this is commonly [but not always] the appropriate behaviour.
    But Marcel seems always to have taken the view that errors should be
    reported. In cases like the present, it's difficult to know whether
    there has been an error or not, so A68G reports the "SIGPIPE" anyway.
    I have an impression that it's "head" or Linux that is inconsistent;
    note that for small values of 2000 ["FOR i to 20 ..."] or large values
    of -2 ["head -1998"] there is no "SIGPIPE". Also, there is no problem
    reported with "tail" ["... | tail | head -2" or even "tail 3000", or
    even "... | head -2 | tail"]. I assume there are differences in what
    is buffered, leading to differences in whether "SIGPIPE" is raised?

    [...]
    Should there be a diagnostic message or not, should such diagnostic
    be interceptable by an event handler or not?

    Pass. But it would be nice if it was consistent!

    What's the rationale for Awk not printing a diagnostic message, but Genie/Algol 68 does?

    Aho et al believe in silent errors, Marcel believes you should
    be told?
    --
    Andy Walker, Nottingham.
    Andy's music pages: www.cuboid.me.uk/andy/Music
    Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Mozart,L
    --- Synchronet 3.21a-Linux NewsLink 1.2