Return value from system() on Linux

S

Sara Shoemaker

Hi all -

I am trying to launch a web browser from within my code for Linux.
The problem is that I am getting no failure code back when the browser
doesn't launch. (I'm trying to force a failure case so I can test the
alert dialog, so I am trying to launch a browser that I know doesn't
exist on my machine).

I am checking the return value from the call to system(), and am
checking the WEXITSTATUS() of the return code, and both evaluate to
0.... which should only happen in case of success.

Is there another way of validating whether a process has launched?
Can I check the current processes from within my code?

Thanks in advance.

-Sara
 
R

Robert Bachmann

Sara said:
Hi all -

I am trying to launch a web browser from within my code for Linux.
The problem is that I am getting no failure code back when the browser
doesn't launch. (I'm trying to force a failure case so I can test the
alert dialog, so I am trying to launch a browser that I know doesn't
exist on my machine).
Your question is off-topic in comp.lang.c
Please try asking in an Linux specific newsgroup.

-rb
 
A

Allin Cottrell

Robert said:
Your question is off-topic in comp.lang.c
Please try asking in an Linux specific newsgroup.

To be a little more expansive, the reason why the question is
best asked elsewhere is that the C standard guarantees very
little about the system() function. Here is what the current
C standard says:

<quote>

#include <stdlib.h>
int system(const char *string);

If string is a null pointer, the system function determines
whether the host environment has a command processor. If
string is not a null pointer, the system function passes
the string pointed to by string to that command processor
to be executed in a manner which the implementation shall
document; this might then cause the program calling system
to behave in a non-conforming manner or to terminate.

If the argument is a null pointer, the system function
returns nonzero only if a command processor is available.
If the argument is not a null pointer, and the system function
does return, it returns an implementation-defined value.

</quote>

Allin Cottrell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top