fork and sockets

Serguei DACHIAN Serguei.Dachian@univ-lemans.fr
Sun Nov 8 02:27:00 GMT 1998


Hi folks. I have some very peculiar problem, and i would really appreciate
any HELP.

I am using B20 + Sergey's X11R6.4 and coolview under Win98.  I have a simple
program which forks a child process.  The child process is working with
sockets.  Immideatly after forking the child process dies dumping core (or
even worth: windows dialog like "this program has performed an illegal
operation ...").  The program works well under Linux, and it works well if I
don't use sockets in the child process.  It also works well if I don't fork,
and use sockets directly in the parent process.  Note that I am not using
Windows sockets but the ordinary UNIX sockets.

If any one can understand what's going on it will be great.

If it can help, here is an example of a main function, giving such a
behaviuor. This program "performs an illegal operation" just after the
hiting some key + enter for a first time, after what the parent process
which is stil alive asks to hit a key+enter for a second time.

int main() {

  int i;
  pid_t childpid;
  char toto[20];

  printf("Hit a key + Enter\n");
  scanf("%s",toto);
  signal (SIGCHLD,SIG_IGN);
  if ((childpid = fork()) < 0) {
    exit (1);
  } else {
    if (childpid == 0) {
      while(1) {
	XXXXXX();
      }
    } else {
      printf("Hit a key + Enter\n");
      scanf("%s",toto);
      kill(childpid,SIGKILL);
      exit (0);
    }
  }
}
Here XXXXXX() is some function using sockets.

Thaks in advance for any help.
___________________________________________________________________________
Serguei DACHIAN
Laboratoire de Statistique et Processus,
Universite du Maine, Av. Olivier Messiaen
72085 Le Mans CEDEX 9, FRANCE
Tel.   : +33 (0)2 43 83 37 18
Fax.   : +33 (0)2 43 83 35 79
E-mail : Serguei.Dachian@univ-lemans.fr
WWW    : http://www.univ-lemans.fr/sciences/statist/cvs/thesard.html#dachian

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list