Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: john@iastate.edu (John Hascall)
Subject: Re: Return Status Codes for system() Function???
Date: 1997/05/24	[thread overview]
Message-ID: <5m7ula$6ft$1@news.iastate.edu> (raw)
In-Reply-To: 3385E815.41C6@klab.caltech.edu


James Bond  <awong@klab.caltech.edu> wrote:
}I'm stumped and hope this newsgroup can help me.
}The return status from system() is 256!?  What does this code mean?
}Note errno is NOT set. errno is still zero.  256 is the int value
}that is returned by system().
}
}According to the man page, system() will return 0 if successful.
}On error system() will return -1 and errno is set. Any other value
}(such as 256!) is the same as wait().  Looking at the wait() man page,
}it tells you to see the wait.h file.  Looking at the wait.h file,
}there is no mention of the 256 return status!  What gives?

   The 'status' returned by wait is a whole bunch
   of bits wedged into an int.  If you look at the
   definitions of WIFEXITED/WEXITSTATUS, etc in
   /usr/include/sys/wait.h you should find that
   FTP is returning a value of '1', that is the
   value looks like:

         +--------+-------+-------+-------+
         |        |       |ret-val|status |
         +--------+-------+-------+-------+       

            (status ==    0)   => process exited with value 'retval'
                    == 0177)   => process stopped, signal# is in retval
                    == other)  => process killed by signal, status is signal#
                                  (if bit 0200 is set, core was dumped)

}Looking at the other header files, there is no clue about the
}return values of system().  Tried looking at the DEC website and
}could not find a list of values. Actually, a list of the possible
}values system() returns and their meanings would be very helpful.

    From "man system":

|RETURN VALUES
|
|  If the string parameter is NULL, the system() function returns 0 if it is
|  unable to access the command interpreter or a non-zero value if sh is
|  accessible.
|
|  If the string parameter is not NULL, upon successful completion by sh, the
|  system() function returns the exit status of the shell process in the form
|  that wait(2) returns.  Otherwise, the system() function returns a value of
|  -1 and sets errno to indicate the error.
|
|  Exit status 127 indicates that the shell could not be executed.
|
|  Note that the exit status should only be interpreted using the macros
|  described in wait(2) and defined in the sys/wait.h header file.


John
-- 
John Hascall, Software Engr.        Shut up, be happy.  The conveniences you
ISU Computation Center              demanded are now mandatory. -Jello Biafra
mailto:john@iastate.edu
http://www.cc.iastate.edu/staff/systems/john/welcome.html  <-- the usual crud



  reply	other threads:[~1997-05-24  4:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-23  4:00 Return Status Codes for system() Function??? James Bond
1997-05-24  4:00 ` John Hascall [this message]
1997-05-24  4:00 ` Gerald A. Feldman
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox