Many thanks but how to implement this kind of procedure SIGCHILD on
the child process.
i have only these informations about ??
http://community.freepascal.org:10000/docs-html/rtl/baseunix/sigchld.html
If i understant the process must wait until the child process send Kill ?
But how to receive the pid form the child process ?
if i understand the function could be ??:
###############################################
Execl(commandline);
fpWaitPid(??,0,WNOHANG);
###############################################
Best rgeardes
Michael Van Canneyt a écrit :
On Tue, 21 Nov 2006, TOUZEAU DAVID wrote:
Dear
my application run has a daemon
When the daemon load, it create a Timer function as a class(TThread).
This Timer thread has a loop and create an another Thread (called "SendStatus"
each 5 minutes)
function that load thread :
###############################################
procedure mTimer.Execute;
var
Pool:integer;
xPool:longint;
Myini:TIniFile;
thread:SendStatus;
begin
while not Terminated do
begin
FConfigFilePath:='/etc/artica/artica-agent.conf';
LoadSettings;
xPool:=(Fpool*60)*1000;
logs('mTimer.Execute->initilize pooling for ' + IntTostr(Fpool) + '
milliseconds for each loop-> '+ IntTostr(Fpool) + ' minutes (from ' +
FConfigFilePath + ')');
LoadSettings;
logs('mTimer.Execute->initilize Thread Sendstatus');
thread:=SendStatus.Create; //Creating the new thread
thread.Resume;//Executing the new thread
thread.free;//Terminate the new thread
logs('mTimer.Execute->kill Thread Sendstatus');
if FMustReload=1 then begin
Myini:=TIniFile.Create(FConfigFilePath);
Myini.WriteInteger('ACTIONS','ReloadSettings',1);
LoadSettings;
xPool:=(Fpool*60)*1000;
logs('mTimer.Execute->Reload settings -> initilize pooling for
' + IntTostr(xPool) + ' milliseconds for each loop');
MyIni.free;
end;
Sleep(xPool);
end;
end;
###############################################
The "SendStatus" execute sometimes an external program writen in fpc called
"articacrypt".
the function just use Execl to execute external program
###############################################
procedure
SendStatus.DeCryptFile(Frompath:string;ToPath:string;PassPharse:string;SETT:KLNetSettings);
var passphrase,commandline,Fbin_path:string;
begin
Fbin_path:=SETT.binaries_path;
if Length(SETT.artica_crypt_key)=0 then begin
SETT.logs('SendStatus.artica_crypt_key -> null aborting..');
exit;
end;
commandline:=Fbin_path + '/articacrypt false ' + Frompath + ' ' +
ToPath + ' ' + PassPharse;
Execl(commandline);
SETT.logs('SendStatus.DeCryptFile -> ' + ToPath + ' was process');
exit;
end;
###############################################
this external program kill itself by calling halt() function at the end of the
code.
My problem is that each execution of this program will add <defunc> in the
Linux system :
example of ps -aux :
root 25992 0.0 0.1 20500 2292 pts/0 Sl 19:45 0:00
/opt/artica/bin/articaagentd
root 26008 0.0 0.0 0 0 pts/0 Z 19:45 0:00 [articacrypt]
<defunct>
root 26009 0.0 0.0 0 0 pts/0 Z 19:45 0:00 [articacrypt]
<defunct>
root 26010 0.0 0.0 0 0 pts/0 Z 19:45 0:00 [articacrypt]
<defunct>
root 26011 0.0 0.0 0 0 pts/0 Z 19:45 0:00 [articacrypt]
<defunct>
root 26012 0.0 0.0 0 0 pts/0 Z 19:45 0:00 [articacrypt]
<defunct>
root 26134 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [articacrypt]
<defunct>
root 26135 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [articacrypt]
<defunct>
root 26136 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [articacrypt]
<defunct>
root 26137 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [articacrypt]
<defunct>
root 26138 0.0 0.0 0 0 pts/0 Z 19:47 0:00 [articacrypt]
<defunct>
root 26247 0.0 0.0 0 0 pts/0 Z 19:49 0:00 [articacrypt]
<defunct>
root 26248 0.0 0.0 0 0 pts/0 Z 19:49 0:00 [articacrypt]
<defunct>
root 26249 0.0 0.0 0 0 pts/0 Z 19:49 0:00 [articacrypt]
<defunct>
root 26250 0.0 0.0 0 0 pts/0 Z 19:49 0:00 [articacrypt]
<defunct>
root 26251 0.0 0.0 0 0 pts/0 Z 19:49 0:00 [articacrypt]
<defunct>
root 26388 0.0 0.0 0 0 pts/0 Z 19:51 0:00 [articacrypt]
<defunct>
root 26389 0.0 0.0 0 0 pts/0 Z 19:51 0:00 [articacrypt]
<defunct>
root 26390 0.0 0.0 0 0 pts/0 Z 19:51 0:00 [articacrypt]
<defunct>
root 26391 0.0 0.0 0 0 pts/0 Z 19:51 0:00 [articacrypt]
<defunct>
root 26392 0.0 0.0 0 0 pts/0 Z 19:51 0:00 [articacrypt]
<defunct>
root 26511 0.0 0.0 0 0 pts/0 Z 19:53 0:00 [articacrypt]
<defunct>
root 26512 0.0 0.0 0 0 pts/0 Z 19:53 0:00 [articacrypt]
<defunct>
root 26513 0.0 0.0 0 0 pts/0 Z 19:53 0:00 [articacrypt]
<defunct>
root 26514 0.0 0.0 0 0 pts/0 Z 19:53 0:00 [articacrypt]
<defunct>
root 26515 0.0 0.0 0 0 pts/0 Z 19:53 0:00 [articacrypt]
<defunct>
root 26662 0.0 0.0 0 0 pts/0 Z 19:55 0:00 [articacrypt]
<defunct>
root 26663 0.0 0.0 0 0 pts/0 Z 19:55 0:00 [articacrypt]
<defunct>
root 26664 0.0 0.0 0 0 pts/0 Z 19:55 0:00 [articacrypt]
<defunct>
root 26665 0.0 0.0 0 0 pts/0 Z 19:55 0:00 [articacrypt]
<defunct>
root 26666 0.0 0.0 0 0 pts/0 Z 19:55 0:00 [articacrypt]
<defunct>
root 26787 0.0 0.0 0 0 pts/0 Z 19:57 0:00 [articacrypt]
<defunct>
root 26788 0.0 0.0 0 0 pts/0 Z 19:57 0:00 [articacrypt]
<defunct>
root 26789 0.0 0.0 0 0 pts/0 Z 19:57 0:00 [articacrypt]
<defunct>
root 26790 0.0 0.0 0 0 pts/0 Z 19:57 0:00 [articacrypt]
<defunct>
root 26791 0.0 0.0 0 0 pts/0 Z 19:57 0:00 [articacrypt]
<defunct>
root 26886 0.0 0.0 0 0 pts/0 Z 19:59 0:00 [articacrypt]
<defunct>
root 26887 0.0 0.0 0 0 pts/0 Z 19:59 0:00 [articacrypt]
<defunct>
root 26888 0.0 0.0 0 0 pts/0 Z 19:59 0:00 [articacrypt]
<defunct>
root 26889 0.0 0.0 0 0 pts/0 Z 19:59 0:00 [articacrypt]
<defunct>
root 26890 0.0 0.0 0 0 pts/0 Z 19:59 0:00 [articacrypt]
<defunct>
root 27035 0.0 0.0 0 0 pts/0 Z 20:01 0:00 [articacrypt]
<defunct>
root 27036 0.0 0.0 0 0 pts/0 Z 20:01 0:00 [articacrypt]
<defunct>
root 27037 0.0 0.0 0 0 pts/0 Z 20:01 0:00 [articacrypt]
<defunct>
root 27038 0.0 0.0 0 0 pts/0 Z 20:01 0:00 [articacrypt]
<defunct>
root 27039 0.0 0.0 0 0 pts/0 Z 20:01 0:00 [articacrypt]
<defunct>
Please how to clean theses "defunct" on the system...??????????????
You must do a fpWaitPID() call for each child process that you create.
The best way to do this is to install a handler.
The SIGCHILD signal is sent to a process whenever a child process exits.
In the SIGCHILD handler, you can then do the fpWaitPID() call.
Michael.
--
David Touzeau -------------------------- Linux Ubuntu Dapper 6.0.6
FreePascal-Lazarus,perl,delphi,php icq:160018849
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal