How to kill an unkillable task? - wmic

I am using Scilab to access a software called LTSpice (XVIIx64.exe) and whenever I use wmic/taskkill/powershell.exe "Get-Process XVIIx64 | Stop-Process". or whatever killing commands, it doesn't actually kill the process (it does close the program, but it still is there in the memory as shown in the picture below). Once I repeat the code in scilab another instance of LTSPICe (XVIIx64.exe) is created in memory and with time there are so many of them that scilab shuts down as it cannot allocate more memory :(. How can I actually kill this process? It's also strange that in the error message it is mentioned PID XXXX "child process of PID 18208" could not be terminated, however PID 18208 does not show up in tasklist and only PID XXXX shows up (View the attachment).

Did you already checked if it is any malware or something? Do that.
If you've done it and got nothing, then get a backup and format your pc. I think that's the best option.

Related

inittab respawn of Node.js too fast

So I am trying to keep my Node server on a embedded computer running when it is out in the field. This lead me to leveraging inittab's respawn action. Here is the file I added to inittab:
node:5:respawn:node /path/to/node/files &
I know for a fact that when I startup this node application from command line, it does not get to the bottom of the main body and console.log "done" until a good 2-3 seconds after I issue the command.
So I feel like in that 2-3 second window the OS just keeps firing off respawns of the node app. I see in the error logs too in fact that the kernel ends up killing off a bunch of node processes because its running out of memory and stuff... plus I do get the 'node' process respawning too fast will suspend for 5 minutes message too.
I tried wrapping this in a script, dint work. I know I can use crontab but thats every minute... am I doing something wrong? or should I have a different approach all together?
Any and all advice is welcome!
TIA
Surely too late for you, but in case someone else finds such a problem: try removing the & from the command invocation.
What happens is that when the command goes to the background (thanks to the &), the parent (init) sees that it exited, and respawns it. Result: a storm of new instantations of your command.
Worse, you mention embedded, so I guess you are using busybox, whose init won't rate-limit the respawning - as would other implementations. So the respawning will only end when the system is out of memory.
inittab is overkill for this. I found out what I need is a process monitor. I found one that is lightweight and effective; it has some good reports of working great out in the field. http://en.wikipedia.org/wiki/Process_control_daemon
Using this would entail configuring this daemon to start and monitor your Node.js application for you.
That is a solution that works from the OS side.
Another way to do it is as follows. So if you are trying to keep Node.js running like I was, there are several modules written meant to keep other Node.js apps running. To mention a couple there are forever and respawn. I chose to use respawn.
This method entails starting one app written in Node.js that uses the respawn module to start and monitor the actual Node.js app you were interested in keeping running anyway.
Of course the downside of this is that if the Node.js engine (V8) goes down altogether then both your monitoring and monitored process will go down with it :-(. But its better than nothing!
PCD would be the ideal option. It would go down probably only if the OS goes down, and if the OS goes down then hope fully one has a watchdog in place to reboot the device/hardware.
Niko

Life of PID in windows

Can any one please tell me about the life of a Process Identification (PID) in Windows Server.
Does it remain same for a long process, I mean after a day or two?
I am saving PIDs in my application and want to evaluate the process on the basis of their IDs.
It doesn't change as long as the process is still running.
http://blogs.msdn.com/b/oldnewthing/archive/2011/01/07/10112755.aspx
If you shut down the program, or kill it, and then restart it, you will get a new process id.
If you start the program you can use Process.WaitForExit. If you are starting the programs, I'd start each process in a new thread and use Process.WaitForExit.
msdn.microsoft.com/en-us/library/fb4aw7b8.aspx
For a different process check out the following website: http://alperguc.blogspot.ca/2008/11/c-process-processgetprocessesbyname.html
It shows how to find a process and attach to it's Exited event.

How to check if another instance of the app/binary is already running

I'm writing a command line application in Mac using Objective-c
At the start of the application, i want to check if another instance of the same application is already running. If it is, then i should be either wait for it to finish or exit the current instance or quit the other instance etc.
Is there any way of doing this?
The standard Unix solution for this is to create a "run file". When you start up, you try to create that file and write your pid to it if it doesn't exist; if it does exist, read the pid out of it, and if there's a running program with that pid and your process name, wait/exit/whatever.
The question is, where do you put that file, and what do you call it?
Well, first, you have to decide what exactly "already running" means. Obviously not "anywhere in the world", but it could be anything from "anywhere on the current machine" to "in the current desktop session". (For example, if User A starts your program, pauses it, then User B comes along and takes over the computer via Fast User Switching, should she be able to run the program, or not?)
For pretty much any reasonable answer to that question, there's an obvious pathname pattern. For example, on a Mac, /tmp is shared system-wide, while $TMPDIR is specific to a given session, so, e.g., /tmp/${ARGV[0]}.pid is a good way to say "only one copy on the machine, period", while ${TMPDIR}/${ARGV[0]}.pid is a good way to say "only one copy per session".
Simple but common way to do this is to check the process list for the name of your executable.
ps - A | grep <your executable name>
Thank you #abarnert.
This is how I have presently implemented. At the start of the main(), I would check if a file named .lock exists in the binary's own directory (I am considering moving it to /tmp). If it is, application exits.
If not, it would create the file.
At the end of the application, the .lock file is removed
I haven't yet written the pid to that file, but I will when exiting the previous instance is required (as of yet I don't need it, but may in the future).
I think PID can be retrieved using
int myPID=[[NSProcessInfo processInfo] processIdentifier];
The program will be invoked by a custom scheduler which is running as a root daemon. So it would be run as root.
Seeing the answers, I would assume that there is no direct method of solving the problem.

Some one help me please, cpumun.exe irritating me

My CPU is running at 100% even though it should be idle. The task manager shows that a single process called 'cpumin.exe' is causing this.
Could anyone please explain what I can do to stop this? As whenever I kill the process, it just starts again.
I have noticed kind of relationship between this process and network, because when I unplug the network cable the computer works well.
And there is something else when I give this process the order "Suspend process" and when you open the "Analyze Wait Chain" I found that this process have this message "One or more threads of cpumin.exe are waiting to finish network I/O".
Thanks...
Someone else had a similar problem here ...
What exactly is the 'cpumin.exe' process which runs in the background and takes up 100% of the CPU? It happens whenever I run a Java program
Probably best to do a full virus scan just in case. According to http://www.threatexpert.com/report.aspx?md5=dd6da7e7b46f199edc8e4a81b2ae5e1e, it could be some sort of mass mailer.
try the following:
Click Start > Run > (type "cmd.exe" without quotation) > Enter
a Command line (black screen will appear) type the following:
taskkill /fi "imagename eq cpumun.exe" /f /t
The above command will surely kill the task and all of its child processes and tree.
cpumin.exe appears to be a virus, see:
http://www.threatexpert.com/report.aspx?md5=dd6da7e7b46f199edc8e4a81b2ae5e1e

Kill process after launching with AuthorizationExecuteWithPrivileges

If I launched a shell script using AuthorizationExecuteWithPrivileges what would be the easiest way to kill the script and any other processes that it spawned.
Thanks
It's running as root, so you can't kill it from a regular-user process. You're going to have to ask it nicely to exit on its own.
Apple has sample code that uses stdout to pass the PID back to the caller.
Use the communications pipe that AuthorizationExecuteWithPrivileges() returns by reference in its last argument, FILE **communicationPipe, to send a message to the child process that asks it to take itself and its descendants out. It can then kill itself and all its descendants using kill(0, SIGINT), or, if more drastic measures are required, SIGKILL.
The message you use can be as simple as closing the file while the child waits for the file to close; at that point, it knows you're done talking to it and it's time to take itself out.
There are some caveats about the descendants that will actually receive this message, for which see the kill(2) manpage. The caveats mostly won't matter so long as the process you started via AEWP hasn't dropped privileges, though one implicit issue is that this approach won't work if any child processes have put themselves in a new process group.