Mail Archives: djgpp/1998/04/09/02:33:47
From: | cwr AT cts DOT com (Will Rose)
|
Newsgroups: | comp.lang.c,comp.os.msdos.djgpp
|
Subject: | Re: Executing a program and obtaining its return value
|
Followup-To: | comp.lang.c,comp.os.msdos.djgpp
|
Date: | 9 Apr 1998 06:11:32 GMT
|
Organization: | CTS Network Services (CTSNET), San Diego, CA
|
Lines: | 28
|
Message-ID: | <892102406.261004@optional.cts.com>
|
References: | <352C1A0D DOT 77EAB402 AT codex DOT nu>
|
NNTP-Posting-Host: | optional.cts.com
|
Cache-Post-Path: | optional.cts.com!cwr AT crash-i2 DOT cts DOT com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Jeff Weeks (info AT codex DOT nu) wrote:
: Hi there,
: I know how I could go about running a program from inside a C program
: (using system or exec*) but neither seem to return the return value of
: the program. Is there an ANSI or POSIX way of obtaining the programs
: return value? If so, how?
Whether system() returns a valid exit code is implementation defined;
to do any better you need some system-specific method such as fork/exec
and wait() under POSIX.
: Also, do you suppose it's portable to return pointers from executables?
: It seems to me that any system would be able to return a pointer pretty
: easily, considering pointers are almost always size_of(int) and int
: seems to be returned all the time. I'm just wondering if there are any
: odd problems I should know about.
You can certainly return a pointer, but what use would it be? Pointers
point to objects in a given processes' address space, and (with rare
exceptions) won't mean anything to another process. What would another
process do with the pointer when it had got it? And if the process
has exited, where would the pointer point to anyway?
Will
cwr AT crash DOT cts DOT com
- Raw text -