Return value from system() on Linux

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sara Shoemaker

    Return value from system() on Linux

    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
  • Robert Bachmann

    #2
    Re: Return value from system() on Linux

    Sara Shoemaker wrote:[color=blue]
    > 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).[/color]
    Your question is off-topic in comp.lang.c
    Please try asking in an Linux specific newsgroup.

    -rb
    --
    Robert.Bachmann @rbdev.net

    Comment

    • Allin Cottrell

      #3
      Re: Return value from system() on Linux

      Robert Bachmann wrote:[color=blue]
      > Sara Shoemaker wrote:
      >[color=green]
      >> 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).[/color]
      >
      > Your question is off-topic in comp.lang.c
      > Please try asking in an Linux specific newsgroup.[/color]

      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

      Comment

      Working...