Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 9th, 2008, 3:47 PM   #11
Lakrids
Newbie
 
Join Date: Dec 2007
Posts: 28
Rep Power: 0 Lakrids is on a distinguished road
Re: Cross-platform exec()

Thanks! But does this mean that on UNIX based systems, in cases where you don't have to do anything (or have to wait) for the child to terminate, it is wiser to use system() than doing

c Syntax (Toggle Plain Text)
  1. pid_t pid = fork();
  2. if (pid==0) {
  3. exec(...)
  4. }
  5. else if (pid != -1) {
  6. wait(status);
  7. }

because for one, it is shorter to write , and second, it is cross-platform (which is pretty much my aim)?
Lakrids is offline   Reply With Quote
Old Jun 9th, 2008, 4:30 PM   #12
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,209
Rep Power: 5 grumpy is on a distinguished road
Re: Cross-platform exec()

Given that command shells (the things executed by system() on unix variants, as an intermediary to executing your string) vary between flavours of unix, and also with whims of system administrators or end users (eg selection of different shells), the action of system("some_string") varies a lot. It is often better to KNOW the results of code, than to rely on system behaviour that can change without your control.
grumpy is offline   Reply With Quote
Old Jun 9th, 2008, 5:42 PM   #13
Sorrofix
Expert Bug Developer
 
Sorrofix's Avatar
 
Join Date: Apr 2008
Posts: 21
Rep Power: 0 Sorrofix is on a distinguished road
Re: Cross-platform exec()

Quote:
Originally Posted by grumpy View Post
That is only true on some target platforms, and with some libraries. It is not a predictable result.

The C standard has this to say on system(), and is all that can relied upon in cross-platform development.
I stand corrected.
Sorrofix is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coder's Block Arena - The Game AI Platform Sane Existing Project Development 23 May 6th, 2008 9:12 PM
Which Flavor: CPython or IronPython and Exec Opts Kigneer Python 2 Apr 6th, 2008 10:36 PM
Php with Sun Java System Application Server Platform lucifer PHP 0 Jun 7th, 2007 4:03 AM
Need help from someone who has downloaded microsoft platform sdk rsnd Other Programming Languages 3 Feb 18th, 2006 5:04 PM
Platform Api jstephens C 3 Jan 2nd, 2006 5:17 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:51 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC