Hi all,

Perhaps this is very basic but I was not able to find the answer in faq/docs.

Attached is a nice small program which does system("cmd /?"); The call
works pretty well when I run it from Cygwin environment. In my
situation I need to run standalone Cygwin programs (i.e. simply from
Windows cmd.exe). In this case the program fails - system() does not
seem to find cmd.exe and returns -1 (yes, cygwin1.dll is on PATH). If
I change system() to good old CreateProcess() everything runs fine. My
questions:
1) what is the reason for this behavior?
2) can I somehow alter the argument to system() to make it working? Or
perhaps modify PATH or any other environment variable before running
Cygwin program?

Thanks in advance,
Yuri
#include <stdlib.h>
#include <stdio.h>

int main() {
        char tmp[256];
        getcwd(tmp, sizeof(tmp));
        printf("Cwd: %s\n", tmp);

        if( 0 != system("cmd /?") ) {
                printf("Failed\n");
        }

        return 0;
}

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to