给定以下代码:
分叉:
if(strcmp(str,"mkDir")==0)
{
str = strtok(NULL," ");
switch(pid_child = fork())
{
case -1:
{
printf("Problem with producing a new process!\n");
exit(1);
break;
}
case 0:
{
wait(1);
strcat(curRoot,str);
strcat(curRoot,"\\");
if(num_dir>0)
{
free(arr);
num_dir=0;
}
if(numFile>0)
{
free(files);
numFile=0;
}
break;
}
default:
{
pid = getpid();
*cur_pid = pid;
arr = add_dir(arr,str,pid_child,&num_dir);
break;
}
}
}//if MKDIR
试图杀死进程:
struct Directory* rmDir(struct Directory* dirs,char* name,int *size)
{
int i,m=0,j;
struct Directory* temp=NULL;
j = find_dir(dirs,name,*size);
if(j==-1)
{
printf("The directory does not exist\n");
return dirs;
}
else
{
temp = (struct Directory*)malloc(sizeof(struct Directory)*((*size)-1));
for (i=0; i<*size;i++)
{
if(i!=j)
{
temp[m]=dirs[i];
m++;
}
}//for
kill(dirs[j].dir_pid,SIGKILL);
(*size)--;
free(dirs);
printf("Directory - %s was removed successfully!\n",name);
return temp;
}
}//rmDir
当我试图杀死“父亲”进程时,子进程继续运行?
这是为什么 ?
问候