Process started by Process.start() returns incorrect process ID?

An example of how I did it: bool started = false; var p = new Process(); p.StartInfo.FileName = “notepad.exe”; started = p.Start(); try { var procId = p.Id; Console.WriteLine(“ID: ” + procId); } catch(InvalidOperationException) { started = false; } catch(Exception ex) { started = false; } Otherwise, try using handles like this: Using handlers Getting … Read more

IIS Application pool PID

On Windows Server 2008 this has changed. in %systemroot%\system32\inetsrv you find the appcmd.exe using appcmd list wp you get a list of all the worker processes and which apppool they are serving. You might need to run this in a shell with Administrator privileges.

Get PID from MS-Word ApplicationClass?

Here is how to do it. //Set the AppId string AppId = “”+DateTime.Now.Ticks(); //A random title //Create an identity for the app this.oWordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); this.oWordApp.Application.Caption = AppId; this.oWordApp.Application.Visible = true; while (GetProcessIdByWindowTitle(AppId) == Int32.MaxValue) //Loop till u get { Thread.Sleep(5); } ///Get the pid by for word application this.WordPid = GetProcessIdByWindowTitle(AppId); ///You canh … Read more

Check if process exists given its pid

Issue a kill(2) system call with 0 as the signal. If the call succeeds, it means that a process with this pid exists. If the call fails and errno is set to ESRCH, a process with such a pid does not exist. Quoting the POSIX standard: If sig is 0 (the null signal), error checking … Read more

Difference between PID and TID

It is complicated: pid is process identifier; tid is thread identifier. But as it happens, the kernel doesn’t make a real distinction between them: threads are just like processes but they share some things (memory, fds…) with other instances of the same group. So, a tid is actually the identifier of the schedulable object in … Read more