kumar_m_kiran
kumar_m_kiran

Reputation: 4022

Windows programming using mingw and system() function call usage

I am from Unix programming background and am facing a unique behavior/problem during porting my system from Unix to Windows.
[I am pretty new to development on windows, so the below question may look too obvious.]

I am porting using mingw and the problem in question is regarding "system()" call provided in Unix and the WEXITSTATUS option.


Question

  1. In Unix, to execute any commands/scripts we have code that uses system() call. The same compiles in mingw - but I want to know if there are any change in behavior between the Unix and Windows version of system() call.
    The windows version of system() call is provided in stdlib of mingw, but am not able to get the exact behavior.

  2. My second question is regarding WEXITSTATUS. Generally, In Unix this is used along with system() command to get the status of the command executed.
    a. Can the same be done with system() of stdlib of mingw?
    b. How to achieve it?


Note :

I have read about createProcess and its subsequent usage in the net - But my idea is to continue with existing code (use system() call itself) and find an alternative to WEIXTSTATUS.


Thanks for your help/suggestion in advance.

Upvotes: 2

Views: 3148

Answers (1)

rubenvb
rubenvb

Reputation: 76609

Look here for Win32 documentation on system: http://msdn.microsoft.com/en-us/library/277bwbdz%28v=VS.100%29.aspx

Note that the system call is subject to the command interpreter on the system, and cmd.exe (Windows command interpreter) works differently than Unix Bash.

Upvotes: 4

Related Questions