Update of bug #68064 (group groff):

                Category:                 General => Core
              Item Group:                    None => Incorrect behaviour
                  Status:                    None => Unreproducible
                 Summary: .sy does not populate systat register => [troff]
`sy` request does not populate `systat` register

    _______________________________________________________

Follow-up Comment #1:

I cannot reproduce this with _groff_ Git HEAD nor any release going back to
November 2014, including the 1.23.0 release in the original report.

Exhibit:

$ uname -mor
5.10.0-38-amd64 x86_64 GNU/Linux
$ printf '.sy /usr/bin/false\n.tm \\n[systat]\n' | ~/groff-HEAD/bin/nroff -U
256
$ printf '.sy /usr/bin/false\n.tm \\n[systat]\n' | ~/groff-1.22.3/bin/nroff
-U
256
$ printf '.sy /usr/bin/false\n.tm \\n[systat]\n' | ~/groff-1.22.4/bin/nroff
-U
256
$ printf '.sy /usr/bin/false\n.tm \\n[systat]\n' | ~/groff-1.23.0/bin/nroff
-U
256


The original reporter may have expected the `systat` register to take on the
value `1` from an exiting _/bin/false_, but this expectation is unwarranted.

Here's how that register is documented in _groff_(7) (in Git HEAD, at any
rate):


Registers
...
   Writable predefined registers
...
     \n[systat]     Return value of system(3); see sy.


The standard C library's _system_(3)'s return value is not merely an exit
status as reported by a POSIX shell, but a full "termination status" or "wait
status" including several flags.

_system_(3):

RETURN VALUE
     The return value of system() is one of the following:

     *  If command is NULL, then a nonzero value if a shell is
        available, or 0 if no shell is available.

     *  If a child process could not be created, or its status could not
        be retrieved, the return value is -1 and errno is set to
        indicate the error.

     *  If a shell could not be executed in the child process, then the
        return value is as though the child shell terminated by calling
        _exit(2) with the status 127.

     *  If all system calls succeed, then the return value is the
        termination status of the child shell used to execute command.
        (The termination status of a shell is the termination status of
        the last command it executes.)

     In the last two cases, the return value is a "wait status" that can
     be examined using the macros described in waitpid(2).  (i.e.,
     WIFEXITED(), WEXITSTATUS(), and so on).


The `systat` value from _/usr/bin/false_ is the same as from a shell running
its "exit" builtin with an argument of "1".


$ printf '.sy exit 1\n.tm \\n[systat]\n' | ~/groff-1.23.0/bin/groff -U
256
$ printf '.sy exit 0\n.tm \\n[systat]\n' | ~/groff-HEAD/bin/groff -U
0


In GNU _troff_, barring the development of additional features, there is
probably not much point trying to write logic around the value of `systat`
beyond testing for a zero or nonzero value.  (In AT&T _troff_, `systat` did
not exist, nor did any equivalent, so users of `sy` had to fire **completely**
blindly.)

Need feedback from submitter, or anyone who _can_ reproduce this report; as
shown, I cannot.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68064>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to