Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Return Status Codes for system() Function???
@ 1997-05-23  4:00 James Bond
  1997-05-24  4:00 ` John Hascall
  1997-05-24  4:00 ` Gerald A. Feldman
  0 siblings, 2 replies; 3+ messages in thread
From: James Bond @ 1997-05-23  4:00 UTC (permalink / raw)



Hello,

I'm stumped and hope this newsgroup can help me.

I'm getting an error code from the system() function (C language)
which doesn't appear to be documented anywhere.  I am invoking
system() which runs a shell script which in turn runs FTP.
However the FTP invocation is failing although system() exits
normally.

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?

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.

I'm working on a DEC Alpha with OSF/1 and the cc compiler that
came with the machine.

Please cc: your reply to my email address below as I don't
read this newsgroup very often. Thank you.

-----------------------------------------------------------
Al Wong, wong@southport.jpl.nasa.gov
The Jet Propulsion Laboratory
Pasadena, California
(818) 795-4928, x234
-----------------------------------------------------------



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Return Status Codes for system() Function???
  1997-05-23  4:00 Return Status Codes for system() Function??? James Bond
@ 1997-05-24  4:00 ` John Hascall
  1997-05-24  4:00 ` Gerald A. Feldman
  1 sibling, 0 replies; 3+ messages in thread
From: John Hascall @ 1997-05-24  4:00 UTC (permalink / raw)



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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Return Status Codes for system() Function???
  1997-05-23  4:00 Return Status Codes for system() Function??? James Bond
  1997-05-24  4:00 ` John Hascall
@ 1997-05-24  4:00 ` Gerald A. Feldman
  1 sibling, 0 replies; 3+ messages in thread
From: Gerald A. Feldman @ 1997-05-24  4:00 UTC (permalink / raw)
  To: Al Wong


James Bond wrote: 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?
>
> 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.
>
> I'm working on a DEC Alpha with OSF/1 and the cc compiler that
> came with the machine.
>
> Please cc: your reply to my email address below as I don't
> read this newsgroup very often. Thank you.

It is important that you supply which version of Digital Unix as well as
the compiler version. The -V compiler option will display the version.
In V3.2X and prior versions,
the c compiler is what we refer to as ACC. In V3.2C aand later V3.2
version we ship DECC which can be used with the -migrate switch.
In V4.0 and later versions, DECC is the default compiler. Also, you
should supply what flags are used. How is thr system() function
prototyped. Did you include <stdlib.h>, or
does your code supply a declaration for system().
--
 Jerry Feldman <gaf@mediaone.net>
 Boston Computer Solutions and Consulting
 http://gaf.ne.mediaone.net/




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-05-24  4:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-05-23  4:00 Return Status Codes for system() Function??? James Bond
1997-05-24  4:00 ` John Hascall
1997-05-24  4:00 ` Gerald A. Feldman

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