From: jeff AT dtv DOT net (Jeff Smart) Subject: gethostby... broken when forked 3 Dec 1997 23:48:35 -0800 Message-ID: <34862B09.3FFE.cygnus.gnu-win32@dtv.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: gnu-win32 AT cygnus DOT com I have found the BSD calls gethostbyname and gethostbyaddr break when they are used in a child process that was forked. I compiled this snippet on Win95 using gnu-win32 b18 with the latest coolview dll and lib dated 26Nov97. The code will always return an exception violation: STATUS_ACCESS_VIOLATION once gethostbyname is called. If fork() is removed, then gethostbyname works.. It appears fork() is screwing these address lookup calls. I do not have the latest sources to find this bug. Has anyone else found this nasty ? Cheers, Jeff [----------------- begin -----------------------] #include #include #include #include int main(argc, argv) int argc; char *argv[]; { struct hostent *hostptr; /* Internet host struct from netdb.h */ char hostname[256]; int childpid; strcpy(hostname, argv[1]); printf("PARENT STARTED PID=%d\n", getpid()); if ((childpid = fork()) < 0) { printf("fork failed\n"); exit(0); } else if (childpid == 0) { /* start child process */ printf("CHILD STARTED PID=%d\n", getpid()); hostptr = gethostbyname(hostname); /* BOMBS HERE */ printf("hostptr = %p\n", hostptr); exit(0); } } [--------------------- end --------------------] - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".