C++ Learning Community Forum
August 01, 2010, 03:09:40 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: system() call?  (Read 371 times)
cfk
N00b!!1
*
Posts: 13


View Profile
« on: August 11, 2009, 11:03:05 PM »

i'm trying to make some kind of shell(unix sh) for fun and i wanted to know how to make my shell call other programs
i found one way by calling
Code:
system("the called app");
are there better alternatives and more portable that the system() call?
ps: i'm coding on win32 with codeblocks cuz VS2008 hates me, freezes and crashes and sorry for my bad english
Logged
myork
Global Moderator
C++ guru
*****
Posts: 1147


View Profile
« Reply #1 on: August 13, 2009, 06:42:53 AM »

Code:
pid_t pid = fork();
if (pid == 0)
{
    exec("the called app");
}
Logged
cfk
N00b!!1
*
Posts: 13


View Profile
« Reply #2 on: August 13, 2009, 10:56:45 PM »

doing some searching about exec() found this
Quote
The
Code:
system()
call will execute an OS shell command as described by a character command string. This function is implemented using fork(), exec() and waitpid().
on a linux documentation site.
thinking how it is implemented in windows....
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!