![]() |
|
|
|
|
|||||||
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| launch a command only if | Minguccio75 | UNIX for Advanced & Expert Users | 10 | 02-16-2007 03:48 AM |
| launch an executable from a C++ program | nadiamihu | High Level Programming | 2 | 11-03-2006 01:59 AM |
| how to Launch an independent process. | deepthi | UNIX for Dummies Questions & Answers | 1 | 03-10-2005 06:12 AM |
| How do you launch an .exe from my app? | kapolani | High Level Programming | 1 | 01-03-2005 02:00 PM |
| launch & monitor process on remote host | mrx | Shell Programming and Scripting | 1 | 10-15-2004 07:20 AM |
|
|
Submit Tools | LinkBack | Thread Tools | 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 09:48 AM. |
| Forum Sponsor | ||
|
|
|
|||
|
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. |
| Thread Tools | |
| Display Modes | |
|
|