[comp.unix.xenix] SCO XENIX bug prevents smail from working correctly.

ag@elgar.UUCP (Keith Gabryelski) (01/19/89)

The SCO XENIX C compiler (mine is version 2.2) does not handle a
return from main() correctly.  A return from main should be the same
as an exit from main.  It isn't.

You can confirm this by compiling, running, and checking the exit
status of:

	main(){ return 0; }

and

	main(){ exit(0); }

(On my machine, a 386 box running 2.3.1 OS and 2.2 dev system
The former's exit status is 1.  The latter's exit status is 0.

Smail uses a return from main().

Smail will always exit (if mail was delivered ok) with a status of `2'
even though the exitstat is 0.

HDB (SCO 2.3.1) barfs (returns exit status info to calling site) on
any status other then `0' from rmail (rmail is linked to smail).
[Sorry Brian, I should have found this earlier.]

`recmail' (news) expects any non-zero return value of MAILER
(/usr/bin/smail) to be an indication of an error and returns mail
while passing the error along to `rn'.  This shows itself to the user
as `rn' barfing after any `R' or `r' command (and returning mail to
you, the sender) even though mail has been sent.  (Mailing to a
moderator would also barf, although I haven't tried it).

The following patch to smail[main.c] will fix this:

212c212
< 	return( exitstat );
---
> 	exit( exitstat );

This gist is, smail must use exit() instead of return to leave main
with a status code.

Pax, Keith
-- 
ag@elgar.CTS.COM         Keith Gabryelski          ...!{ucsd, crash}!elgar!ag

davidsen@steinmetz.ge.com (William E. Davidsen Jr) (01/20/89)

In article <31@elgar.UUCP> ag@elgar.UUCP (Keith Gabryelski) writes:
| 
| The SCO XENIX C compiler (mine is version 2.2) does not handle a
| return from main() correctly.  A return from main should be the same
| as an exit from main.  It isn't.

  There was a discussion of this in one of the C groups, and my
recollection of the result was that this is the way C works. When you
exit(status) the result is defined, and if you return(status) it isn't
always the same.
-- 
	bill davidsen		(wedu@ge-crd.arpa)
  {uunet | philabs}!steinmetz!crdos1!davidsen
"Stupidity, like virtue, is its own reward" -me

chip@vector.UUCP (Chip Rosenthal) (01/20/89)

In article <31@elgar.UUCP> ag@elgar.UUCP (Keith Gabryelski) writes:
>The SCO XENIX C compiler (mine is version 2.2) does not handle a
>return from main() correctly.  A return from main should be the same
>as an exit from main.  It isn't.

[ I post because I ran into this ... and I site I helped just recently
ran into it too.  Bet we aren't the only ones... ]

There has been an update to development system 2.2.0 which fixes this
problem.  I have two 96tpi floppies labelled UFC1 and UFC2.  You might
want to contact SCO about this update.
-- 
Chip Rosenthal     chip@vector.UUCP    |      Choke me in the shallow water
Dallas Semiconductor   214-450-5337    |         before I get too deep.

vipoon@kepler1.UUCP (Victor I Poon) (01/20/89)

In article <31@elgar.UUCP> ag@elgar.UUCP (Keith Gabryelski) writes:
>
>The SCO XENIX C compiler (mine is version 2.2) does not handle a
>return from main() correctly.  A return from main should be the same
>as an exit from main.  It isn't.
>

	Interestingly enough, SCO fixed this problem in their
development system patch.  It updates the development system
to 2.2.1 and the return 0 works.  You can order this through
SCO.  The disk number is xnx060.


Victor
-- 
Victor I. Poon				{acsm, sbcs, polyof}!kepler1!vipoon
Kepler Financial Management, Ltd.
You make more of me, I'll make more of you	- Red Jack

daveh@marob.MASA.COM (Dave Hammond) (01/20/89)

In article <31@elgar.UUCP> ag@elgar.UUCP (Keith Gabryelski) writes:
>The SCO XENIX C compiler (mine is version 2.2) does not handle a
>return from main() correctly.  A return from main should be the same
>as an exit from main.  It isn't.
>You can confirm this by compiling, running, and checking the exit
>status of:
>	main(){ return 0; }
>and
>	main(){ exit(0); }
>(On my machine, a 386 box running 2.3.1 OS and 2.2 dev system
>The former's exit status is 1.  The latter's exit status is 0.

Hmmm ...

[ tested on a SCO 386 box, 2.3.1 OS, 2.2 DS ]

$ echo "main(){exit(0);}" >foo.c
$ cc foo.c
$ a.out
$ echo $?
$ 0
$ echo "main(){return(0);}" >foo.c
$ cc foo.c
$ a.out
$ echo $?
$ 0
$ echo "main(){exit(1);}" >foo.c
$ cc foo.c
$ a.out
$ echo $?
$ 1
$ echo "main(){return(1);}" >foo.c
$ cc foo.c
$ a.out
$ echo $?
$ 1

Hmmm ...  [BTW, smail works fine on our SCO 2.2 and 2.3 OS's]

Perhaps you're running a hacked-up shell?

--
Dave Hammond
...!uunet!masa.com!{marob,dsix2}!daveh

ag@elgar.UUCP (Keith Gabryelski) (01/24/89)

In article <58@kepler1.UUCP> vipoon@kepler1.UUCP (Victor I Poon) writes:
>In article <31@elgar.UUCP> ag@elgar.UUCP (Keith Gabryelski) writes:
>>The SCO XENIX C compiler (mine is version 2.2) does not handle a
>>return from main() correctly.
>
>Interestingly enough, SCO fixed this problem in their development
>system patch.  You can order this through SCO.  The disk number is
>xnx060.

I just sent for the fix.  lng060 is the correct disk number, FYI.

Pax, Keith

-- 
ag@elgar.CTS.COM         Keith Gabryelski          ...!{ucsd, crash}!elgar!ag