[cvsnt] Re: CVSNT reuses same PID....

Bo Berglund Bo.Berglund at system3r.se
Tue Dec 17 14:39:38 GMT 2002


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


Answer myself for anybody interested in the technique:

Task: Based on PID get the start time of the process

Solution (Pascal code):

function GetCVSStartTime(PID: Cardinal): Cardinal;
var
	Handle: Cardinal;
	TimCreate, TimExecute, TimKernel, TimUser : FILETIME;	
begin
	Result := 0;
	Handle := OpenProcess(PROCESS_ALL_ACCESS, false, PID);
	if Handle = NULL then exit;
	if not GetProcessTimes(H, TimCreate, TimExecute, TimKernel, TimUser) then exit;
	Result := TimCreate.dwLowDateTime;
end;

/Bo
-----Original Message-----
From: Bo Berglund [mailto:Bo.Berglund at system3r.se]
Sent: den 17 december 2002 12:42
To: cvsnt at cvsnt.org cvsnt downloads at march-hare.com @CVSNT on Twitter CVSNT on Facebook
Subject: RE: [cvsnt] Re: CVSNT reuses same PID....


-----Original Message-----
From: Tony Hoyle [mailto:tmh at nodomain.org]
Sent: den 17 december 2002 11:36
To: cvsnt at cvsnt.org cvsnt downloads at march-hare.com @CVSNT on Twitter CVSNT on Facebook
Subject: [cvsnt] Re: CVSNT reuses same PID....


>Bo Berglund wrote:

>> Now I just want to have someone tip me on how to differentiate between
>> different cvs invocations of the loginfo script. What CVSNT does is
>> start a cvs.exe process when the user sends in a commit. Then this cvs
>> process loops through all submodules and calls the loginfo script
>> repeatedly. I want to collect all of this output in a single message,
>> so I create a temp dir where I store it for a short period until the
>> last call is done. The temp dir name is derived from the PID of the
>> main cvs.exe process as retrieved via $CVSPID.

>You can't assume a PID won't be reused after the cvs.exe has terminated. 
>Under Unix the recycling takes quite a while.  It seems NT recycles
>quickly.  Your script shouldn't be assuming that the PID is unique - it is
>only guaranteed to be 'not the same as other running processes', which is
>not the same thing.  This is why commit scripts are usually combinations of
>loginfo and commitinfo - commitinfo happens after all the loginfo
>processing has completed.
>
>Tony

I was rather hoping for a longer time before reuse, but it turned out to not be the case...
So now I am trying to get hold of some info regarding the running cvs process that will be
fairly unique, like its start time in ticks or similar given that I know the PID of the
process.

And I think it is the opposite concerning the commitinfo/loginfo scripts. Commitinfo
is run before the commit is actually done and can block its execution if it finds that
some aspect of the commit is in error. cvs waits for it to complete. When cvs is done
committing all changes the loginfo script executes, so this is after the fact really.
I tried collecting my info in commitinfo at first, but that solution would only be
applicable to commits, and left tags and notifications out in the cold. So I stopped that
track.

Do you know of an API that can take a PID and get the process start time from Windows?
That would probably be sufficiently unique for my purposes.

/Bo

_______________________________________________
cvsnt mailing list
cvsnt at cvsnt.org cvsnt downloads at march-hare.com @CVSNT on Twitter CVSNT on Facebook
http://www.cvsnt.org/cgi-bin/mailman/listinfo/cvsnt https://www.march-hare.com/cvspro/en.asp#downcvs




More information about the cvsnt mailing list
Download the latest CVSNT, TortosieCVS, WinCVS etc. for Windows 8 etc.
@CVSNT on Twitter   CVSNT on Facebook