• Is EXIT_SUCCESS/EXIT_FAILURE necessary?

    From wij@wyniijj5@gmail.com to comp.lang.c++ on Wed Nov 20 11:02:49 2024
    From Newsgroup: comp.lang.c++

    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of programs for some reason, but generally, exit code of program is a numerical value. Why EXIT_SUCCESS?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Paavo Helde@eesnimi@osa.pri.ee to comp.lang.c++ on Wed Nov 20 09:22:07 2024
    From Newsgroup: comp.lang.c++

    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of programs for some reason, but generally, exit code of program is a numerical value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted
    to cover more different platforms than POSIX style exit codes. The idea
    was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to
    true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers
    (esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@DastartdlyHQ.org to comp.lang.c++ on Wed Nov 20 08:27:11 2024
    From Newsgroup: comp.lang.c++

    On Wed, 20 Nov 2024 09:22:07 +0200
    Paavo Helde <eesnimi@osa.pri.ee> boring babbled:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. >> But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of
    programs for some reason, but generally, exit code of program is a numerical >> value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted
    to cover more different platforms than POSIX style exit codes. The idea
    was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to >true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers >(esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.

    Even within Posix return values are inconsistent. Most posix functions
    return -1 for failure, >= 0 for success and set errno, not so the pthread_*() functions which return the errno directly on failure and zero for success.
    A poor decision IMO.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Wed Nov 20 13:44:19 2024
    From Newsgroup: comp.lang.c++

    wij <wyniijj5@gmail.com> writes:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. >But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of >programs for some reason, but generally, exit code of program is a numerica= >l
    value. Why EXIT_SUCCESS?


    The unix shell interprets the exit code. A script can determine whether
    a command succeeded or failed and take the appropriate action based on
    the exit code. A zero return indicates the command was successful, a
    non-zero return indicates failure.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Wed Nov 20 13:47:53 2024
    From Newsgroup: comp.lang.c++

    Muttley@DastartdlyHQ.org writes:
    On Wed, 20 Nov 2024 09:22:07 +0200
    Paavo Helde <eesnimi@osa.pri.ee> boring babbled:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. >>> But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of >>> programs for some reason, but generally, exit code of program is a numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted >>to cover more different platforms than POSIX style exit codes. The idea >>was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values >>contradict the conventions of C and C++ where 1 is normally converted to >>true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers >>(esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.

    Even within Posix return values are inconsistent. Most posix functions
    return -1 for failure, >= 0 for success and set errno, not so the pthread_*() >functions which return the errno directly on failure and zero for success.
    A poor decision IMO.

    Before POSIX.4 was introducted (pthreads), the convention was return -1
    for failure with ERRNO set.

    With the introduction of multi-threaded programs by POSIX.4, the
    convention -for new posix functions- is to return ERRNO directly
    to avoid using the global (or in modern systems thread-specific)
    errno. This was a deliberate choice by the POSIX.4 working group.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From wij@wyniijj5@gmail.com to comp.lang.c++ on Wed Nov 20 22:57:25 2024
    From Newsgroup: comp.lang.c++

    On Wed, 2024-11-20 at 13:44 +0000, Scott Lurndal wrote:
    wij <wyniijj5@gmail.com> writes:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of programs for some reason, but generally, exit code of program is a numerica=
    l
    value. Why EXIT_SUCCESS?


    The unix shell interprets the exit code.  A script can determine whether
    a command succeeded or failed and take the appropriate action based on
    the exit code.   A zero return indicates the command was successful, a non-zero return indicates failure.
    That is my point. Scripts see number not C/C++ symbol EXIT_SUCCESS.
    Programs can be written in various languages. How to make these programs
    read the C/C++ macro "EXIT_SUCCESS"? And, as it is 'POSIX', that means
    All kind of OS should recognize "EXIT_SUCCESS" to be portable. I doubt this. IMO, 0 is more portable than EXIT_SUCCESS. But, there should be some
    details I don't know. Besides, defining EXIT_SUCCESS has a draw back that programs will have problem to use a range of numbers as exit code. Not allowed? As said I don't know the rationale.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@DastartdlyHQ.org to comp.lang.c++ on Wed Nov 20 15:05:52 2024
    From Newsgroup: comp.lang.c++

    On Wed, 20 Nov 2024 13:47:53 GMT
    scott@slp53.sl.home (Scott Lurndal) boring babbled:
    Muttley@DastartdlyHQ.org writes:
    Even within Posix return values are inconsistent. Most posix functions >>return -1 for failure, >= 0 for success and set errno, not so the pthread_*()

    functions which return the errno directly on failure and zero for success. >>A poor decision IMO.

    Before POSIX.4 was introducted (pthreads), the convention was return -1
    for failure with ERRNO set.

    With the introduction of multi-threaded programs by POSIX.4, the
    convention -for new posix functions- is to return ERRNO directly
    to avoid using the global (or in modern systems thread-specific)
    errno. This was a deliberate choice by the POSIX.4 working group.

    Without changing every other posix function behaviour its a pointless gesture that just causes confusion as errno will still be used elsewhere.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Michael S@already5chosen@yahoo.com to comp.lang.c++ on Wed Nov 20 17:23:22 2024
    From Newsgroup: comp.lang.c++

    On Wed, 20 Nov 2024 22:57:25 +0800
    wij <wyniijj5@gmail.com> wrote:
    On Wed, 2024-11-20 at 13:44 +0000, Scott Lurndal wrote:
    wij <wyniijj5@gmail.com> writes:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. But, is it necessary? E.g. can it be put into shell
    script? I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good
    within a group of programs for some reason, but generally, exit
    code of program is a numerica= l
    value. Why EXIT_SUCCESS?


    The unix shell interprets the exit code.  A script can determine
    whether a command succeeded or failed and take the appropriate
    action based on the exit code.   A zero return indicates the
    command was successful, a non-zero return indicates failure.

    That is my point. Scripts see number not C/C++ symbol EXIT_SUCCESS.
    Programs can be written in various languages. How to make these
    programs read the C/C++ macro "EXIT_SUCCESS"? And, as it is 'POSIX',
    that means All kind of OS should recognize "EXIT_SUCCESS" to be
    portable. I doubt this. IMO, 0 is more portable than EXIT_SUCCESS.
    But, there should be some details I don't know. Besides, defining EXIT_SUCCESS has a draw back that programs will have problem to use a
    range of numbers as exit code. Not allowed? As said I don't know the rationale.



    On POSIX and on many other OSes conventions are like you said. But it
    is not universal. One example of different conventions is VMS.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Wed Nov 20 15:45:03 2024
    From Newsgroup: comp.lang.c++

    Muttley@DastartdlyHQ.org writes:
    On Wed, 20 Nov 2024 13:47:53 GMT
    scott@slp53.sl.home (Scott Lurndal) boring babbled:
    Muttley@DastartdlyHQ.org writes:
    Even within Posix return values are inconsistent. Most posix functions >>>return -1 for failure, >= 0 for success and set errno, not so the pthread_*()

    functions which return the errno directly on failure and zero for success. >>>A poor decision IMO.

    Before POSIX.4 was introducted (pthreads), the convention was return -1
    for failure with ERRNO set.

    With the introduction of multi-threaded programs by POSIX.4, the
    convention -for new posix functions- is to return ERRNO directly
    to avoid using the global (or in modern systems thread-specific)
    errno. This was a deliberate choice by the POSIX.4 working group.

    Without changing every other posix function behaviour its a pointless gesture >that just causes confusion as errno will still be used elsewhere.


    That was clearly not the opinion of the POSIX working group.

    Anyone confused by the fact that the interface set is not
    completely uniform probably needs to look for a different
    job if they are unable to RTFM
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Muttley@Muttley@DastartdlyHQ.org to comp.lang.c++ on Wed Nov 20 16:41:14 2024
    From Newsgroup: comp.lang.c++

    On Wed, 20 Nov 2024 15:45:03 GMT
    scott@slp53.sl.home (Scott Lurndal) boring babbled:
    Muttley@DastartdlyHQ.org writes:
    On Wed, 20 Nov 2024 13:47:53 GMT
    scott@slp53.sl.home (Scott Lurndal) boring babbled: >>>Muttley@DastartdlyHQ.org writes:
    Even within Posix return values are inconsistent. Most posix functions >>>>return -1 for failure, >= 0 for success and set errno, not so the >pthread_*()

    functions which return the errno directly on failure and zero for success. >>>>A poor decision IMO.

    Before POSIX.4 was introducted (pthreads), the convention was return -1 >>>for failure with ERRNO set.

    With the introduction of multi-threaded programs by POSIX.4, the >>>convention -for new posix functions- is to return ERRNO directly
    to avoid using the global (or in modern systems thread-specific)
    errno. This was a deliberate choice by the POSIX.4 working group.

    Without changing every other posix function behaviour its a pointless gesture >>that just causes confusion as errno will still be used elsewhere.


    That was clearly not the opinion of the POSIX working group.

    Committees don't always make the best decision as the current state of C++ demonstrates.

    Anyone confused by the fact that the interface set is not
    completely uniform probably needs to look for a different
    job if they are unable to RTFM

    If you think consistency within an API is unimportant then I suggest it
    might be you who belongs in another career.

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++ on Wed Nov 20 13:37:17 2024
    From Newsgroup: comp.lang.c++

    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of
    programs for some reason, but generally, exit code of program is a
    numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted
    to cover more different platforms than POSIX style exit codes. The idea
    was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers (esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?

    Returning 0 on such a system would return EXIT_SUCCESS such that the
    system would say its success?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Wed Nov 20 22:11:46 2024
    From Newsgroup: comp.lang.c++

    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of >>> programs for some reason, but generally, exit code of program is a
    numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted
    to cover more different platforms than POSIX style exit codes. The idea
    was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to
    true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers
    (esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++ on Wed Nov 20 14:33:46 2024
    From Newsgroup: comp.lang.c++

    On 11/20/2024 2:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of >>>> programs for some reason, but generally, exit code of program is a
    numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted >>> to cover more different platforms than POSIX style exit codes. The idea
    was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to >>> true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers
    (esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    What about the strict C std, posix aside for a moment?
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Wed Nov 20 23:03:45 2024
    From Newsgroup: comp.lang.c++

    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/20/2024 2:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of >>>>> programs for some reason, but generally, exit code of program is a
    numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted >>>> to cover more different platforms than POSIX style exit codes. The idea >>>> was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to >>>> true and 0 to false. So to reduce confusion it might be a good idea to >>>> use the macros even here. Note that nowadays there are many programmers >>>> (esp. on Windows) who have no idea about program exit code conventions >>>> or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    What about the strict C std, posix aside for a moment?

    I would assume that is entirely up to the implementation. So
    long as the value defined in stdlib.h agrees with the value that
    the rest of the implementation (e.g. powershell/cmd.exe)
    expects.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++ on Wed Nov 20 15:57:27 2024
    From Newsgroup: comp.lang.c++

    On 11/20/2024 3:03 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/20/2024 2:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of
    programs for some reason, but generally, exit code of program is a >>>>>> numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted >>>>> to cover more different platforms than POSIX style exit codes. The idea >>>>> was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether >>>>> the program is compiled to run on some Unix, on some weird mainframe >>>>> with weird exit code values, or in some free-standing implementation >>>>> where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to >>>>> true and 0 to false. So to reduce confusion it might be a good idea to >>>>> use the macros even here. Note that nowadays there are many programmers >>>>> (esp. on Windows) who have no idea about program exit code conventions >>>>> or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    What about the strict C std, posix aside for a moment?

    I would assume that is entirely up to the implementation. So
    long as the value defined in stdlib.h agrees with the value that
    the rest of the implementation (e.g. powershell/cmd.exe)
    expects.

    Agreed!
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Chris M. Thomasson@chris.m.thomasson.1@gmail.com to comp.lang.c++ on Wed Nov 20 15:58:23 2024
    From Newsgroup: comp.lang.c++

    On 11/20/2024 2:33 PM, Chris M. Thomasson wrote:
    On 11/20/2024 2:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a
    group of
    programs for some reason, but generally, exit code of program is a
    numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was
    attempted
    to cover more different platforms than POSIX style exit codes. The idea >>>> was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally
    converted to
    true and 0 to false. So to reduce confusion it might be a good idea to >>>> use the macros even here. Note that nowadays there are many programmers >>>> (esp. on Windows) who have no idea about program exit code conventions >>>> or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system.  EXIT_SUCCESS must be zero.  EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    What about the strict C std, posix aside for a moment?

    Actually, for some reason, this makes me think of nullptr = 0 = NULL wrt
    NULL can be 0xdeadbeefbeefdead?


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ross Finlayson@ross.a.finlayson@gmail.com to comp.lang.c++ on Wed Nov 20 17:32:01 2024
    From Newsgroup: comp.lang.c++

    On 11/20/2024 02:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different
    programs.
    But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of >>>> programs for some reason, but generally, exit code of program is a
    numerical
    value. Why EXIT_SUCCESS?



    EXIT_SUCCESS is an attempt to provide an abstraction which was attempted >>> to cover more different platforms than POSIX style exit codes. The idea
    was that one can use EXIT_SUCCESS and EXIT_FAILURE regardless whether
    the program is compiled to run on some Unix, on some weird mainframe
    with weird exit code values, or in some free-standing implementation
    where there is no OS, not to speak about shell scripts.

    Even on Linux or Windows, note that the exit code numeric values
    contradict the conventions of C and C++ where 1 is normally converted to >>> true and 0 to false. So to reduce confusion it might be a good idea to
    use the macros even here. Note that nowadays there are many programmers
    (esp. on Windows) who have no idea about program exit code conventions
    or shell scripts.



    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    Thanks that's interesting as sometimes one sees 255.

    It's great that the return code may be structured, yet
    because anything non-zero might be lost usually there's
    only "= EXIT_SUCCESS" and "!= EXIT_SUCCESS", or as with
    regards to shell syntax where expressions in shell commands
    have that conditionally "command1 && command2" executes command2
    iff command1 results EXIT_SUCCESS, which equals 0 most everywhere,
    though that being the opposite of a usual arithmetic expression
    where true = non-zero and false = zero, as with regards to
    the error case being 1, or 1-125, or 255, or INT_MAX, or 0xFFFFFFFF.

    Anyways an error of whatever value might get translated to
    "err..." for example 1 or 255, so, it's usual to test only
    that "= EXIT_SUCCESS" or "= 0" the code, while it's usually
    considered clear that "exit 0" is "exit EXIT_SUCCESS" while
    "exit 1" is any "not EXIT_SUCCESS".

    As a structured return code otherwise the semantics of
    main according to POSIX, structured return codes is a
    great idea unfortunately very particular to usage,
    and as well the runtime and as well any interpreter.


    "Portable-subset-of-POSIX-ly a process-model-ing", ....



    This being not relevant to C++ largely and rather the runtime
    I'll now obligatorily Ctrl-w myself a bunch of times,
    yet the constants in the headers are for returning them
    from main, only, pretty much, that being defined.


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++ on Wed Nov 20 23:09:14 2024
    From Newsgroup: comp.lang.c++

    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of programs for some reason, but generally, exit code of program is a numerical value. Why EXIT_SUCCESS?

    Because which numeric values qualify as successful and failure codes
    varies from one operating system to another. My own experience includes
    VMS, where even exit codes indicate errors, whereas odd value indicate
    success. Notice that this is incompatible with the POSIX convention of 0
    for success, non-zero for failure. On a VMS system, a conforming version
    of the C standard library must have exit(0) report an odd exit status; EXIT_SUCCESS might be the same odd number, or a different one.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From James Kuyper@jameskuyper@alumni.caltech.edu to comp.lang.c++ on Wed Nov 20 23:20:03 2024
    From Newsgroup: comp.lang.c++

    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/20/2024 2:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/19/2024 11:22 PM, Paavo Helde wrote:
    On 20.11.2024 05:02, wij wrote:
    ...
    EXIT_SUCCESS can be 0xbeefbeef and EXIT_FAILURE can be 0xdeadbeef?


    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    What about the strict C std, posix aside for a moment?

    The only requirements are that EXIT_FAILURE and EXIT_SUCCESS must
    "expand to integer constant expressions that can be used as the argument
    to the exit function to return unsuccessful or successful termination
    status, respectively, to the host environment;" (7.24p4) It's completely
    up to the implementation which expressions are used, and there's no
    requirement that there be a direct connection between the value passed
    to exit() and the numeric value received by the host environment. In
    fact, there's no requirement that the status be in the form of an
    integer value.

    A value of 0 passed to exit() must also result in returning a successful termination status to the host environment. EXIT_SUCCESS is not required
    to expand to an integer constant expression with a value of 0, nor is it prohibited from doing so.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From red floyd@no.spam.here@its.invalid to comp.lang.c++ on Wed Nov 20 22:56:53 2024
    From Newsgroup: comp.lang.c++

    On 11/20/2024 5:32 PM, Ross Finlayson wrote:

    Thanks that's interesting as sometimes one sees 255.

    I believe that in POSIX, exit codes between 128 to 128 + NSIG inclusive indicate the termination was caused by a signal.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Thu Nov 21 13:43:30 2024
    From Newsgroup: comp.lang.c++

    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 11/20/2024 2:33 PM, Chris M. Thomasson wrote:
    On 11/20/2024 2:11 PM, Scott Lurndal wrote:


    Actually, for some reason, this makes me think of nullptr = 0 = NULL wrt >NULL can be 0xdeadbeefbeefdead?


    I've worked with systems where the NULL pointer value was not zero.

    That's why C has a symbolic constant for NULL.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Thu Nov 21 13:51:36 2024
    From Newsgroup: comp.lang.c++

    Ross Finlayson <ross.a.finlayson@gmail.com> writes:
    On 11/20/2024 02:11 PM, Scott Lurndal wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:

    Not on any POSIX system. EXIT_SUCCESS must be zero. EXIT_FAILURE
    must be between 1 and 125 inclusive.

    https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/stdlib.h.html


    Thanks that's interesting as sometimes one sees 255.

    Any exit value with bit<7> set indicates that the process
    was terminated by a fatal signal (typ. SIGSEGV) and a
    core file was generated on most
    unix and unix-like kernels.

    /* Nonzero if STATUS indicates the child dumped core. */
    #define __WCOREDUMP(status) ((status) & __WCOREFLAG)
    #define __WCOREFLAG 0x80

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Thu Nov 21 13:52:09 2024
    From Newsgroup: comp.lang.c++

    red floyd <no.spam.here@its.invalid> writes:
    On 11/20/2024 5:32 PM, Ross Finlayson wrote:

    Thanks that's interesting as sometimes one sees 255.

    I believe that in POSIX, exit codes between 128 to 128 + NSIG inclusive >indicate the termination was caused by a signal.

    Acutally bit<7> set indicates that a core file was generated.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From scott@scott@slp53.sl.home (Scott Lurndal) to comp.lang.c++ on Thu Nov 21 13:52:58 2024
    From Newsgroup: comp.lang.c++

    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 20.11.2024 05:02, wij wrote:
    EXIT_SUCCESS/EXIT_FAILURE are for communication between different programs. >> But, is it necessary? E.g. can it be put into shell script?
    I think the macro EXIT_SUCCESS/EXIT_FAILURE may be good within a group of
    programs for some reason, but generally, exit code of program is a numerical >> value. Why EXIT_SUCCESS?

    Because which numeric values qualify as successful and failure codes
    varies from one operating system to another. My own experience includes
    VMS, where even exit codes indicate errors, whereas odd value indicate >success.

    Indeed, and SS$_NORMAL (a success indication) had the value 0x1.
    --- Synchronet 3.20a-Linux NewsLink 1.114