•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,565 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 3454 | Replies: 7
![]() |
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation:
Rep Power: 40
Solved Threads: 972
You can't do any of those things with system() function. You need to use more os-specific api calls. MS-Windows use CreateProcess(), don't know about *nix.
•
•
Join Date: Jan 2007
Location: Maryland, USA
Posts: 1,036
Reputation:
Rep Power: 4
Solved Threads: 23
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation:
Rep Power: 40
Solved Threads: 972
No you don't run cmd.exe at all, read about the parameters at MSDN here -- the second-to-last parameter has an option to run the process without a window. And CreateProcess() will run without waiting for the process to finish.
>>for *nix I think you can postfix your command with &.
I don't think that works inside a c++ program, only from a shell program.
>>for *nix I think you can postfix your command with &.
I don't think that works inside a c++ program, only from a shell program.
•
•
Join Date: Jan 2007
Location: Maryland, USA
Posts: 1,036
Reputation:
Rep Power: 4
Solved Threads: 23
>I don't think that works inside a c++ program, only from a shell program.
No it works. Just tested it.
starts emacs and returns immediately
No it works. Just tested it.
c++ Syntax (Toggle Plain Text)
#include<iostream> using namespace std; int main() { system("emacs&"); return 0; }
starts emacs and returns immediately
Last edited by Sturm : Jun 19th, 2007 at 8:43 pm.
"Hey ass, don't hijack my thread. This is serious." -JoshSCH
•
•
Join Date: Feb 2007
Location: Bangalore, India
Posts: 535
Reputation:
Rep Power: 4
Solved Threads: 50
If you don't wanna be platform dependent you can still do this by forking a thread for system(). Should be simple enough as well.
c Syntax (Toggle Plain Text)
pid = fork() ; if( 0 == pid ) system("...") ; //your normal code here..
Are you Agile.. ?
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Can we execute command line cmds from a php file?? (PHP)
- Execute unix command from perl running on windows (Perl)
Other Threads in the C++ Forum
- Previous Thread: please tell me what the reason to use reference parameter?
- Next Thread: Dll Writing



Linear Mode