delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/01/16/20:17:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <20040117011732.53374.qmail@web20305.mail.yahoo.com>
Date: Sat, 17 Jan 2004 02:17:32 +0100 (CET)
From: =?iso-8859-1?q?Pierre=20Mallard?= <pierremallard AT yahoo DOT fr>
Subject: Problem using kill for child process
To: cygwin AT cygwin DOT com
MIME-Version: 1.0

Hi,
Maybe this is a little bit stupid from me but it
appears I got some problem killing an innocent child
process (I show the code below ...)

Got Cygwin from cygwin.com about 15 days ago...running
on Windows2000

If I call from my parent process a simple kill(pid)
then it doesn't stop the child process at all, or
maybe after more than one minute but I don't think
so...
If I send from my parent process a kill(pid,x) where x
is 1 or 9, then when I wait after in parent for child
termination with waitfunction I have a segmentation
fault during wait...
PS if parent is killed with Ctrl-C, I can kill child
then from shell with kill pid
Thanks for your help
Pierre

#include <unistd.h>
#include <sys\types.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

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

pid_t pid;
int times = 10;
int i;

pid=fork();
if (pid < 0){
	return 1;
}
else if (pid == 0){ //Child
	while(1){
	sleep(5);
	printf("Child\n");fflush(stdout);
	}
	return 0;
}
else{//Parent
	for(i=1;i<=times;i++){
		sleep(1);
		printf("Parent\n");fflush(stdout);
	}
	printf("Killing Child (pid %d)\n",pid);
	kill(pid); //Or kill(pid,1)
	printf("Waiting for child to terminate\n");
	wait(); //Seg Fault if kill(pid,1)
        //Wait till tomorrow if kill(pid)
	printf("Exiting\n");fflush(stdout);
	return 0;
}
}

=====
Pierre Mallard 
4 rue Auguste Marin
94100 Saint Maur des Fossés

tel : (0033)  148838749
       (0033)  666351977

_________________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019