Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #120928 > unrolled thread
| Started by | wij <wyniijj5@gmail.com> |
|---|---|
| First post | 2024-11-20 11:02 +0800 |
| Last post | 2025-02-15 16:21 -0800 |
| Articles | 12 on this page of 92 — 19 participants |
Back to article view | Back to comp.lang.c++
Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-20 11:02 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-20 09:22 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastartdlyHQ.org - 2024-11-20 08:27 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-20 13:47 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastartdlyHQ.org - 2024-11-20 15:05 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-20 15:45 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastartdlyHQ.org - 2024-11-20 16:41 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 13:37 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-20 22:11 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 14:33 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-20 23:03 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 15:57 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 15:58 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-21 13:43 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastartdlyHQ.org - 2024-11-21 16:07 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-21 17:55 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? David Brown <david.brown@hesbynett.no> - 2024-11-22 09:30 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ross Finlayson <ross.a.finlayson@gmail.com> - 2024-11-22 11:10 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@dastardlyhq.com - 2024-11-23 11:36 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-11-22 12:26 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-22 12:49 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-22 23:26 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? David Brown <david.brown@hesbynett.no> - 2024-11-23 13:07 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-11-25 13:55 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-01 20:57 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastartdlyHQ.org - 2024-11-22 09:55 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-11-26 04:21 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-22 11:57 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-22 11:31 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-11-22 12:36 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-22 16:53 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-24 12:57 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-11-25 14:03 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-26 12:21 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-27 16:23 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastartdlyHQ.org - 2024-11-27 08:26 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-27 18:48 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-27 15:39 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-27 13:54 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-27 17:24 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-27 16:12 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Richard Damon <richard@damon-family.org> - 2024-11-27 13:00 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-28 08:23 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-28 15:06 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Richard Damon <richard@damon-family.org> - 2024-11-28 08:08 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-27 14:58 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ross Finlayson <ross.a.finlayson@gmail.com> - 2024-11-27 19:46 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-28 08:26 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-28 13:03 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ralf Fassel <ralfixx@gmx.de> - 2024-11-28 12:15 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-28 13:36 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ralf Fassel <ralfixx@gmx.de> - 2024-11-28 14:12 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Richard Damon <richard@damon-family.org> - 2024-11-28 07:50 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-28 15:19 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-28 15:12 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-28 17:36 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? David Brown <david.brown@hesbynett.no> - 2024-11-28 16:43 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-28 15:59 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ross Finlayson <ross.a.finlayson@gmail.com> - 2024-11-28 10:19 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-28 22:41 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-29 00:21 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-29 00:59 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-29 01:20 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-28 17:18 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Paavo Helde <eesnimi@osa.pri.ee> - 2024-11-27 19:01 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-28 08:22 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ross Finlayson <ross.a.finlayson@gmail.com> - 2024-11-27 11:00 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-27 14:57 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Muttley@DastardlyHQ.org - 2024-11-27 13:52 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-27 14:54 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-28 15:27 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-27 15:30 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-11-28 18:32 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-11-25 14:00 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-25 14:15 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-12-01 21:00 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-11-26 04:26 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-20 23:20 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Ross Finlayson <ross.a.finlayson@gmail.com> - 2024-11-20 17:32 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? red floyd <no.spam.here@its.invalid> - 2024-11-20 22:56 -0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-21 13:52 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-21 13:51 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-20 13:44 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-20 22:57 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Michael S <already5chosen@yahoo.com> - 2024-11-20 17:23 +0200
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-11-20 23:09 -0500
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? scott@slp53.sl.home (Scott Lurndal) - 2024-11-21 13:52 +0000
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? wij <wyniijj5@gmail.com> - 2024-11-21 22:45 +0800
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Rosario19 <Ros@invalid.invalid> - 2024-11-25 22:20 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? "Fred. Zwarts" <F.Zwarts@HetNet.nl> - 2024-11-26 10:20 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Rosario19 <Ros@invalid.invalid> - 2024-11-30 16:52 +0100
Re: Is EXIT_SUCCESS/EXIT_FAILURE necessary? Andrey Tarasevich <noone@noone.net> - 2025-02-15 16:21 -0800
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2024-11-21 13:52 +0000 |
| Message-ID | <dWG%O.12796$vGnb.9356@fx46.iad> |
| In reply to | #120958 |
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.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2024-11-21 13:51 +0000 |
| Message-ID | <IVG%O.12795$vGnb.8078@fx46.iad> |
| In reply to | #120955 |
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
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2024-11-20 13:44 +0000 |
| Message-ID | <TIl%O.42745$LlWc.34928@fx42.iad> |
| In reply to | #120928 |
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.
[toc] | [prev] | [next] | [standalone]
| From | wij <wyniijj5@gmail.com> |
|---|---|
| Date | 2024-11-20 22:57 +0800 |
| Message-ID | <5816e79b8e072d927620544854d76bba6e7db894.camel@gmail.com> |
| In reply to | #120935 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Date | 2024-11-20 17:23 +0200 |
| Message-ID | <20241120172322.00007f8e@yahoo.com> |
| In reply to | #120937 |
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.
[toc] | [prev] | [next] | [standalone]
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2024-11-20 23:09 -0500 |
| Message-ID | <vhmbq5$ggpd$1@dont-email.me> |
| In reply to | #120928 |
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.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2024-11-21 13:52 +0000 |
| Message-ID | <_WG%O.12797$vGnb.5582@fx46.iad> |
| In reply to | #120956 |
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.
[toc] | [prev] | [next] | [standalone]
| From | wij <wyniijj5@gmail.com> |
|---|---|
| Date | 2024-11-21 22:45 +0800 |
| Message-ID | <79de3322f5766bc602cd3e034c56cc77ff27bc8c.camel@gmail.com> |
| In reply to | #120956 |
On Wed, 2024-11-20 at 23:09 -0500, James Kuyper 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? > > 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. It reads to me that 0 is more portable. Unless some POSIX OS uses non-zero for success.
[toc] | [prev] | [next] | [standalone]
| From | Rosario19 <Ros@invalid.invalid> |
|---|---|
| Date | 2024-11-25 22:20 +0100 |
| Message-ID | <ubq9kjl5rear8fhb1kgt1n25fm4i04k9dm@4ax.com> |
| In reply to | #120928 |
On Wed, 20 Nov 2024 11:02:49 +0800, wij <wyniijj5@gmail.com> 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 the success is one only case
and failure can happen for 10000000 of causes differents
the success has to be one number
and failure all the remain numbers
as example 0 success -inf .. +inf -{0} failure
[toc] | [prev] | [next] | [standalone]
| From | "Fred. Zwarts" <F.Zwarts@HetNet.nl> |
|---|---|
| Date | 2024-11-26 10:20 +0100 |
| Message-ID | <vi43s7$3ckrl$1@dont-email.me> |
| In reply to | #121015 |
Op 25.nov.2024 om 22:20 schreef Rosario19:
> On Wed, 20 Nov 2024 11:02:49 +0800, wij <wyniijj5@gmail.com> 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 the success is one only case
> and failure can happen for 10000000 of causes differents
> the success has to be one number
> and failure all the remain numbers
> as example 0 success -inf .. +inf -{0} failure
In some situations there can be different success cases, as well.
E.g. when searching for something, both finding something and finding
nothing is a valuable result and not a failure of the search operation.
It is worthwhile to indicate them with different success codes.
That can be done in VMS where odd codes are all success codes.
One could also think of a success code that includes the number of
results. (That is what many I/O functions do: A positive value indicates
a success with the number of bytes transferred, a negative number
indicates a failure.)
Failures are a different thing; they make the result of the operation
invalid. They should be indicated with an error code.
[toc] | [prev] | [next] | [standalone]
| From | Rosario19 <Ros@invalid.invalid> |
|---|---|
| Date | 2024-11-30 16:52 +0100 |
| Message-ID | <hvcmkjlum8s58of7q46u4dl4a9hfbtri4g@4ax.com> |
| In reply to | #121023 |
On Tue, 26 Nov 2024 10:20:07 +0100, "Fred. Zwarts"
<F.Zwarts@HetNet.nl> wrote:
>Op 25.nov.2024 om 22:20 schreef Rosario19:
>> On Wed, 20 Nov 2024 11:02:49 +0800, wij <wyniijj5@gmail.com> 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 the success is one only case
>> and failure can happen for 10000000 of causes differents
>> the success has to be one number
>> and failure all the remain numbers
>> as example 0 success -inf .. +inf -{0} failure
>
>In some situations there can be different success cases, as well.
>E.g. when searching for something, both finding something and finding
>nothing is a valuable result and not a failure of the search operation.
>It is worthwhile to indicate them with different success codes.
ok but for me it is better "What return" is the error code, and the
number of results it finds can be in a variable linked to the function
>That can be done in VMS where odd codes are all success codes.
>One could also think of a success code that includes the number of
>results. (That is what many I/O functions do: A positive value indicates
>a success with the number of bytes transferred, a negative number
>indicates a failure.)
>Failures are a different thing; they make the result of the operation
>invalid. They should be indicated with an error code.
[toc] | [prev] | [next] | [standalone]
| From | Andrey Tarasevich <noone@noone.net> |
|---|---|
| Date | 2025-02-15 16:21 -0800 |
| Message-ID | <vorb2t$8io0$1@dont-email.me> |
| In reply to | #120928 |
On Tue 11/19/2024 7:02 PM, 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? On can point out that `EXIT_SUCCESS` is "not necessary" in exactly the same way macro `NULL` is "not necessary". The language spec explicitly states that every time you do return `0` from `main`, the actual value returned to the hosting environment is the environment-specific "success" value. It means that when you do `return 0`, it does not mean that integer `0` is actually returned to the host (even on systems that support integral returns). The environment might actually receive `1`, `42`, `255`, `3.14` or "ok". The implementation is required to _translate_ the value. And the process of translation of `0` into the appropriate "success value" in return-from-main contexts takes place outside of `EXIT_SUCCESS` macro. Regardless of how `EXIT_SUCCESS` is defined, you can always return `0` instead of returning `EXIT_SUCCESS` and get the same effect. Implementations are free to define `EXIT_SUCCESS` as something different from `0`, but there's no need to since defining it as `0` will always work anyway. This is very similar to `NULL`: you can always use `0` in place of `NULL`, and while it is possible to define `NULL` as something different from `0`, defining it as `0` will always work anyway. So, is `NULL` necessary or unnecessary? Meanwhile, `EXIT_FAILURE` is different, since there's no translation mechanism for non-zero return values. And this might hint at one reason for `EXIT_FAILURE`'s existence: since the "success" value is not necessarily zero (on the host's side), using an arbitrary non-zero value as a "failure" value might result in an unintended collision with devastating consequences. For example, the host might use integer 255 as the "success" value (meaning that `return 0` will actually result in 255 being returned to the host), whilst the program's author might unknowingly employ 255 as indicator of some specific error. If non-translated integer 255 ends up returned to the host, the host will see it as a success value. This is where `EXIT_FAILURE` comes in. `EXIT_FAILURE` is there to provide you with _at_ _least_ _one_ return value that _definitely_ does not collide with "success" value on the host's side. So, `EXIT_SUCCESS` is not necessary, aside from providing optimistically-sounding mnemonic. `EXIT_FAILURE` is kinda necessary... albeit it provides the kind of portability that is usually left unrequested in practice. -- Best regards, Andrey
[toc] | [prev] | [standalone]
Page 5 of 5 — ← Prev page 1 2 3 4 [5]
Back to top | Article view | comp.lang.c++
csiph-web