程序执行后退出 返回Killed
我的程序里面有这么一句话:kill((goose_var+g)->ntid,SIGKILL);
上下文是这样: sprintf(warning,"%02x%02x%100s%08x%02x%02x%02x%02x%02x",0x00,0x01,"file_name",4294967,0x00,0x28,(goose_ctr+g)->Appid[0],(goose_ctr+g)->Appid[1],0);
alarm_report(warning);
kill((goose_var+g)->ntid,SIGKILL); //这句话在这里
(goose_var+g)->timepro_usec=0;
(goose_var+g)->COUNTALL=0;
(goose_var+g)->stNum1=0;
(goose_var+g)->stNum_pro=0;
(goose_var+g)->sqNum1=0;
(goose_var+g)->sqNum_pro=0;
(goose_var+g)->ntid=0;
(goose_var+g)->Stnum_Change=0;
(goose_var+g)->POINT=0;
//kill((goose_var+g)->ntid,SIGKILL); //这句话在这里
当像上面这样加上这句话之后,是没有问题的,但是如果把这句话加到最后面,程序执行到这句话,终端打印“Killed”,并且退出。这是怎么回事呢?
------解决方案--------------------(goose_var+g)->ntid=0;
这里有一句赋值, 导致如下结果:
If pid is 0, sig shall be sent to all processes (excluding an unspecified set of system processes)
whose process group ID is equal to the process group ID of the sender, and for which the process
has permission to send a signal.