473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Nov 14 '05 #1
2 13225
Sara Shoemaker wrote:
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
--
Ro*************@rbdev.net
Nov 14 '05 #2
Robert Bachmann wrote:
Sara Shoemaker wrote:
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.


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
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: ~Gee | last post by:
Hi Folks! Please see the program below: 1 #include<iostream> 2 #include<list> 3 #include <unistd.h> 4 using namespace std; 5 int main() 6 { 7 {
5
by: Jeong-Gun Lee | last post by:
I'm writing a code of writing a value to a specific memory address. ================================================================= #include <stdio.h> int main() { long air; long...
14
by: William Ahern | last post by:
is this legal: FILE *func(void) { extern int errno; return (errno = EINVAL, NULL); } my compiler (gcc 2.9.x on openbsd) is complaining that i'm returning a pointer from int w/o a cast....
7
by: hugo27 | last post by:
obrhy8 June 18, 2004 Most compilers define EOF as -1. I'm just putting my toes in the water with a student's model named Miracle C. The ..h documentation of this compiler does state that when...
5
by: Bas Wassink | last post by:
Hi there, I was wondering what the standard (C89) states what the minimum value of FOPEN_MAX should be? K&R just state that FOPEN_MAX is implementation-defined and when googling for an answer I...
12
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. ...
13
by: vashwath | last post by:
Hi all, To test the return value of system I wrote 2 programs which are shown below. Program 1: #include <stdio.h> #include <stdlib.h> int main(void)
3
by: Allerdyce.John | last post by:
Hi, In my code, I have a function which has a return value in the declaration: bool myFunction( int a) { // my implmentation }
7
by: getridofthespam | last post by:
Hi all, Why doesn't _tzset return an error when the TZ environment variable does not contain a valid timezone? Other question: how to check the timezone is a valid one? Thanks for all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.