Menu

fork() problem

2005-11-19
2012-09-26
  • Nobody/Anonymous

    Hi, All!

    I'm developing the C software with Dev-C++4.9.9.2/gcc 3.4 on the Win XP.

    Everthing was good but I met a problem.

    fork() function is not noticed in this IDE.
    Of course, the same source code was compiled on RedHat linux(gcc 3.2)
    My test source is as follows:

    include <sys/types.h>

    include <unistd.h>

    include <stdio.h>

    int main(int argc, char *argv[])
    {

    int pid;
    pid = fork();
    switch(pid)
    {
    case -1:
    perror("fork failed");
    break;
    default:
    break;
    }
    return 0;
    }

     
    • Nobody/Anonymous

      I was going to do exactly that, however I was afraid people might actually try to look up the documentation on C functions such as posix() or windows() ;-)

       
    • Nobody/Anonymous

      no fork under windows, use win api

       
    • Anonymous

      Anonymous - 2005-11-19

      While the compiler is GCC, the C runtime library is Microsoft'd MSVCRT.DLL rather than glib. Moreover, the process model in Win32 is significantly different from that of Linux, so the semantics of fork() are not supported.

      If you want to run Linux code on Windows without porting, you need to use the Cygwin Linux emulation layer and toolchain - you can coerce Dev-C++ into using this toolchain, but Cygwin itself is a large download and installation.

      Clifford

       
    • Nobody/Anonymous

      fork: posix
      windows: not posix
      fork: not under windows

      if you want to create processes or threads there are win32 functions, too. Just check the MSDN or this forum.

       
      • Anonymous

        Anonymous - 2005-11-20

        Perhaps if the forum were written in Prolog it could answer these questions automatically? ;-)

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.