Menu

#1444 MinGW system() not POSIX-compliant

Known_Feature
closed-invalid
nobody
2010-06-21
2010-06-21
No

According to the POSIX specs, the system() function should have the same effect as sh -c "...". Apparently this is not the case.

$ sh -c 'set -x; (echo abc)'
+ echo abc
abc

$ ./system-test.exe 'set -x; (echo abc)'
Executing set -x; (echo abc) ...
Environment variable -x; (echo abc) not defined

See also http://www.opengroup.org/onlinepubs/000095399/functions/system.html for more information.

Setup details:

Host OS: Windows 7, 32-bit.
gcc version:
$ gcc -v
Reading specs from c:/mingw/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)
$ ld -v
GNU ld (GNU Binutils) 2.20.51.20100613
Version of mingwrt: 3.18

Discussion

  • Bart Van Assche

    Bart Van Assche - 2010-06-21

    Test program source code.

     
  • Earnie Boyd

    Earnie Boyd - 2010-06-21
    • milestone: --> Known_Feature
    • status: open --> closed-invalid
     
  • Earnie Boyd

    Earnie Boyd - 2010-06-21

    Yes, Windows is not POSIX compliant. Windows never said that it was. MinGW uses the MSVCRT runtime. You must do as Windows does. Check MSDN for the documentation for the use of the system() function.

     
  • Bart Van Assche

    Bart Van Assche - 2010-06-22

    Thanks for the feedback.