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?
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/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?
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.
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 whetherThat is my point. Scripts see number not C/C++ symbol EXIT_SUCCESS.
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.
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.
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 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.
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
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.
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?
"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
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?
"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.
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?
"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
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?
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?
Thanks that's interesting as sometimes one sees 255.
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?
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.
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.
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.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 991 |
Nodes: | 10 (1 / 9) |
Uptime: | 75:55:09 |
Calls: | 12,949 |
Calls today: | 3 |
Files: | 186,574 |
Messages: | 3,264,532 |