Does linux schedule a process or a thread?

The Linux scheduler (on recent Linux kernels, e.g. 3.0 at least) is scheduling schedulable tasks or simply tasks. A task may be : a single-threaded process (e.g. created by fork without any thread library) any thread inside a multi-threaded process (including its main thread), in particular Posix threads (pthreads) kernel tasks, which are started internally … Read more

How to use [DllImport(“”)] in C#?

You can’t declare an extern local method inside of a method, or any other method with an attribute. Move your DLL import into the class: using System.Runtime.InteropServices; public class WindowHandling { [DllImport(“User32.dll”)] public static extern int SetForegroundWindow(IntPtr point); public void ActivateTargetApplication(string processName, List<string> barcodesList) { Process p = Process.Start(“notepad++.exe”); p.WaitForInputIdle(); IntPtr h = p.MainWindowHandle; SetForegroundWindow(h); … Read more

How do you kill all Linux processes that are older than a certain age?

Found an answer that works for me: warning: this will find and kill long running processes ps -eo uid,pid,etime | egrep ‘^ *user-id’ | egrep ‘ ([0-9]+-)?([0-9]{2}:?){3}’ | awk ‘{print $2}’ | xargs -I{} kill {} (Where user-id is a specific user’s ID with long-running processes.) The second regular expression matches the a time that … Read more

How to get Command Line info for a process in PowerShell or C#

In PowerShell you can get the command line of a process via WMI: $process = “notepad.exe” Get-WmiObject Win32_Process -Filter “name=”$process”” | Select-Object CommandLine Note that you need admin privileges to be able to access that information about processes running in the context of another user. As a normal user it’s only visible to you for … Read more

How do I attach Visual Studio to a process that is not started yet?

Actually you can; you don’t attach to it, you start it. On the properties of your project, on the Debugging tab, specify the path of the program you want to attach to in the “Command” textbox. You can also enter any command-line arguments for the program in the “Command Arguments” box: Ensure that “Attach” is … Read more

Delphi – get what files are opened by an application

Using the Native API function NtQuerySystemInformation you can list all open handles from all processes. try this example program ListAllHandles; {$APPTYPE CONSOLE} uses PSApi, Windows, SysUtils; const SystemHandleInformation = $10; STATUS_SUCCESS = $00000000; STATUS_BUFFER_OVERFLOW = $80000005; STATUS_INFO_LENGTH_MISMATCH = $C0000004; DefaulBUFFERSIZE = $100000; type OBJECT_INFORMATION_CLASS = (ObjectBasicInformation,ObjectNameInformation,ObjectTypeInformation,ObjectAllTypesInformation,ObjectHandleInformation ); SYSTEM_HANDLE=packed record uIdProcess:ULONG; ObjectType:UCHAR; Flags :UCHAR; Handle :Word; … Read more