Subject: fork and sockets
From: [email-masked] (Serguei DACHIAN)

8 Nov 1998 11:05:23 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
To: [email-masked]

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 : [email-masked]
WWW    : http://www.univ-lemans.fr/sciences/statist/cvs/thesard.html#dachian

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".