![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| launch a command only if | Minguccio75 | UNIX for Advanced & Expert Users | 10 | 02-16-2007 07:48 AM |
| launch an executable from a C++ program | nadiamihu | High Level Programming | 2 | 11-03-2006 05:59 AM |
| how to Launch an independent process. | deepthi | UNIX for Dummies Questions & Answers | 1 | 03-10-2005 10:12 AM |
| How do you launch an .exe from my app? | kapolani | High Level Programming | 1 | 01-03-2005 06:00 PM |
| launch & monitor process on remote host | mrx | Shell Programming and Scripting | 1 | 10-15-2004 10:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to launch a new process
Hi, I have a situation where a C main program needs to call another C main program, my background is mostly Windows and I'm new to UNIX programming. I've read about system(), fork(), and exec() and I'm a little confused as to what the sequence of steps should be to launch another process. By the way the parent program would have to suspend execution until the child program returns and parent program would need to read the return or exit code of the child program. Thank you in advance for your help.
![]() Last edited by hr94131; 05-05-2008 at 12:48 PM.. |
|
||||
|
system() costs mainly the memory for a shell instance. It's secure when the programmer considers the environement (variables) to be unreliable/hostile.
One has to consider what's more important: simplicity of code (system()) or efficiency (fork(), exec(), ...) |
|
||||
|
Last time I checked system() was deprecated in that it uses /bin/sh -c and is a security risk due to set(u|g)id privilege escalation and environment manipulation attacks.
There's a good case that spawning a shell to execute a command is not a good idea (as shamrock noted) if a simple exec will suffice. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|