pid

Auto-restart system in Python

I need to detect when a program crashes or is not running using python and restart it. I need a method that doesn't necessarily rely on the python module being the parent process. I'm considering implementing a while loop that essentially does ps -ef | grep process name and when the process isn't found it starts another. Perhaps thi...

How to do a search for PID? (bash)

Hi, assuming that I know the PID of a process and want to do a search in ps -A, how do I do it? I tried doing this: echo "Enter PID to search: " read PID search=$(ps -A | grep -v PID | awk '{print $1}') This returns me with a long list of PIDs. So how can I get use each individual value of the output and do: if [ "$PID" = "*each_val...

PID assignment policy in Windows / Using PIDs for naming temporary files

What is the PID assignment policy in Windows? Repeated runs of a process calling _getpid() indicates non sequential assignment (3548,3344,3628,2748,4872,2360). Given the observed non sequential assignment of PIDs, is it possible for two different process with the same pid to be executed closely in time from one another? Obviously the ...

Looking to get the env vars of a PID in BASH for a BASH script.

Any way to do this? I have a script that exports a few vars and runs a component. I'm looking to find out the actual values of some of these vars while the process is running. (Which applies here, because I'll be incorporating those values into another script/program) The vars themselves are PID specific (I'm quite new at this, if tha...

Identify the PID of a Executing Batch File in Powershell

Hi, I need to identify the P(rocess) ID of an executing batch file from a PowerShell (v1.0) script. Can anyone suggest a way of doing this? Thanks, MagicAndi. ...

Port 80 is being used by SYSTEM (PID 4), what is that?

I am trying to use port 80 for my application server, but when I perform "netstat -aon" I get TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 4 When I look up the process in task manager, it shows PID 4 is SYSTEM, thats it, not extension... nothing, just "SYSTEM". Whats going on here? I'm afraid to end this process, what do I do? UPDATE: I've ...

Python: module for creating PID-based lockfile?

I'm writing a Python script that may or may not (depending on a bunch of things) run for a long time, and I'd like to make sure that multiple instances (started via cron) don't step on each others toes. The logical way to do this seems to be a PID-based lockfile… But I don't want to re-invent the wheel if there is already code to do this...

How to determine if a process ID exists.

I'm using C# .NET 2.0. I need to determine if a PID exists. I came up with the following code: private bool ProcessExists(int iProcessID) { foreach (Process p in Process.GetProcesses()) { if (p.Id == iProcessID) { return true; } } return false; } Is there a better way to do this ot...

How can I implement a multi-threaded PID controller in Java?

I'm kinda new to Java, so haven't yet fully grasped the concept of multithreading.I would like to create a PIDController class that allows me to do this: ControllerMethods methods = new ControllerMethods() { public long getError(long setpoint) { ...

How to get the PID of a process that is piped to another process in Bash?

Hi, I am trying to implement a simple log server in Bash. It should take a file as a parameter and serve it on a port with netcat. ( tail -f $1 & ) | nc -l -p 9977 But the problem is that when the netcat terminates, tail is left behind running. (Clarification: If I don't fork the tail process it will continue to run forever even the ...

How can I force a refresh of what ports have listeners

I'm trying to re-launch a WCF service that I killed earlier, but I'm getting an AddressAlreadyInUseException. The port it's attempting to use is 1819. I ran netstat -nao from the command line, and have found there is a listening process on port 1819, that has a PID of 4840. I went into Process Explorer (from SysInternals) to try to ki...

The best way to ensure only 1 copy of bash script is running?

What is the simplest/best way to ensure only 1 copy of given script is running - assuming it's bash on linux? At the moment I'm doing: ps -C script.name.sh > /dev/null 2>&1 || ./script.name.sh but it has several issues: it puts the check outside of script it doesn't let me run the same script from separate accounts - which I would ...

How to send signal to JVM created by JNI_CreateJavavm call?

Hello Guys Is there any possibility that I can directly send signal to a Java virtual machine which is created by calling JVM_CreateJavavm in native C/C++ code? e.g.: For a normal Java process, say its pid is 12345, I can send a signal 3 to it like this ... kill -3 12345, and hopefully I could trigger javacore or heapdump by changing...

How to capture the PID of a process when launching it in DOS

Is there a way to do this purely in a .bat file? The purpose is to launch iexplore, then kill just that instance when it's finished.. ...

PID of last started process in Bash-Script

i am using the program synergy together with an ssh tunnel it works, i just have to open an console an type these two commands: ssh -f -N -L localhost:12345:otherHost:12345 otherUser@OtherHost synergyc localhost because im lazy i made an Bash-Script which is run with one mouseclick on an icon: #!/bin/bash ssh -f -N -L localhost:123...

os.kill not raising an OSError, however I do not see the given pid running

On my ubuntu server I run the following command: python -c 'import os; os.kill(5555, 0)' This is done so that I can see if pid 5555 is running. From my understanding this should raise an OSError if the pid is not running. This is not raising an OSError for me which means it should be a running process. However when I run: ps aux |...

After forced quit, "killall Finder" says "No matching processes..." but PID still exists?

Here's one for ya. Upon a forced quit of the Finder with unsuccessful relaunch, "killall Finder" in terminal returns: "No matching processes belonging to you were found" Oddly enough, the PID for finder does actually show up after a "ps -A" to reveal all processes. But the time is perpetually listed as 0:00:00, upon repeated PID listi...

Getting pid and details for topmost window

Does anyone know how to get the PID of the top active window and then how to get the properties of the window using the PID? I mean properties like process name, program name, etc. I'm using Qt under Linux (Ubuntu 9.10). ...

How to redirect stdin from my app to another knowing its PID (C,in windows)

I have a script vbs wich redirect some data to the stdin of myApp (written in C in Windows). If myApp was already launched before myApp finds the PID of the first myApp session and redirects the input received via stdin to the stdin of the first session of myApp which handles the stdin. So when myApp receives a stdin and no other instanc...

FluorineFX Aperture in Adobe AIR: How to get program standard output?

I have next command to run from my AIR application: chp.exe cmd /d /c ""process.bat" "params.tmp" > "log.tmp" 2>&1 && echo 0 > status.tmp" || echo 1 > "status.tmp"" It creates background invisible process and logs output and exit status of the process.bat to the log.tmp and status.tmp. chp.exe is a "Create Hidden Process" program (...