os.Exit only send 0 or 1 at the exit

29 views
Skip to first unread message

Archos

unread,
Nov 7, 2011, 7:23:45 PM11/7/11
to golang-nuts
os.Exit() only send 2 values of exit; using 0 it sends 0, but for
whatever another number it always sends 1

===
package main

import "os"

func main() {
os.Exit(2)
}
===

It can be checked, after of run that code, with:

echo $?

Rob 'Commander' Pike

unread,
Nov 7, 2011, 7:39:26 PM11/7/11
to Archos, golang-nuts
tubenose=% cat x.go
package main

import "os"

func main() {
os.Exit(2)
}
tubenose=% 6g x.go
tubenose=% 6l x.6
tubenose=% 6.out
tubenose=% echo $?
2
tubenose=%

Be more specific about architecture and operating system. My run was amd64 on darwin.

-rob

Brad Fitzpatrick

unread,
Nov 7, 2011, 7:41:49 PM11/7/11
to Rob 'Commander' Pike, Archos, golang-nuts
I tested tip on both Linux and Darwin amd64.  Both fine.

Archos

unread,
Nov 7, 2011, 7:47:05 PM11/7/11
to golang-nuts
Sorry! it's correct.

I run it from gonow, a program to link and run automatically, so it's
masking the exit of the program to compile.
Reply all
Reply to author
Forward
0 new messages