process-management

Change priority of the current process in C

泪湿孤枕 提交于 2019-12-04 01:46:33
On Windows I can do: HANDLE hCurrentProcess = GetCurrentProcess(); SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS); How can I do the same thing on *nix? Try: #include <sys/time.h> #include <sys/resource.h> int main(){ setpriority(PRIO_PROCESS, 0, -20); } Note that you must be running as superuser for this to work. (for more info, type 'man setpriority' at a prompt.) If doing something like this under unix your want to (as root) chmod you task and set the s bit. Then you can change who you are running as, what your priority is, your thread scheduling, etc. at run time. It is

What happens to my app when my Mac goes to sleep?

不想你离开。 提交于 2019-12-03 05:58:45
问题 When Mac OS X goes to sleep, due to closing a laptop or selecting "Sleep" from the Apple menu, how does it suspend an executing process? I suppose non-windowed processes are simply suspended at an arbitrary point of execution. Is that also true for Cocoa apps, or does the OS wait until control returns to the run loop dispatcher, and goes to sleep in a "known" location? Does any modern OS do that, or is it usually safe enough to simply suspend an app no matter what it is doing? I'm curious,

What happens to my app when my Mac goes to sleep?

梦想的初衷 提交于 2019-12-02 19:20:05
When Mac OS X goes to sleep, due to closing a laptop or selecting "Sleep" from the Apple menu, how does it suspend an executing process? I suppose non-windowed processes are simply suspended at an arbitrary point of execution. Is that also true for Cocoa apps, or does the OS wait until control returns to the run loop dispatcher, and goes to sleep in a "known" location? Does any modern OS do that, or is it usually safe enough to simply suspend an app no matter what it is doing? I'm curious, because allowing sleep to occur at any moment means, from the app's perspective, the system clock could

How to find the process id of a running Java process on Windows? And how to kill the process alone?

邮差的信 提交于 2019-12-02 18:03:55
I want to kill the particular Java process in Windows, like in Linux ( ps -aux to get processid and then kill processid to kill the process). You can use the jps utility that is included in the JRE to find the process id of a Java process. The output will show you the name of the executable JAR file or the name of the main class. Then use the Windows task manager to terminate the process. If you want to do it on the command line, use TASKKILL /PID %PID% You can also find the PID of a java program with the task manager. You enable the PID and Command Line columns View -> Select Columns and are

Draining Standard Error in Java

南笙酒味 提交于 2019-12-01 20:01:13
When launching a process from Java, both stderr and stdout can block on output if I don't read from the pipes. Currently I have a thread that pro-actively reads from one and the main thread blocks on the other. Is there an easy way to join the two streams or otherwise cause the subprocess to continue while not losing the data in stderr? Set the redirectErrorStream property on ProcessBuilder to send stderr output to stdout: ProcessBuilder builder = new ProcessBuilder(command); builder.redirectErrorStream(true); You should then create a thread to deal with the process stream, something like the

Why is PM2 not launching my Node process?

£可爱£侵袭症+ 提交于 2019-12-01 09:26:12
Previously I have had success implementing PM2, but not currently. My node app does run just fine if I start it manually, but nothing I do gets it to run via PM2, even though PM2 appears to be starting it up. Here's what I mean: If I run pm2 start server/index.js, the response in the terminal reads: $ pm2 start server/index.js [PM2] Spawning PM2 daemon with pm2_home=c:\pm2_system\.pm2 [PM2] PM2 Successfully daemonized [PM2] Starting D:\Program Files\nodeApps\service-management-api\server\index.js in fork_mode (1 instance) [PM2] Done.* Then the terminal prints out a table with App info. It

Tracing which process that has opened a particular file

陌路散爱 提交于 2019-11-30 07:38:56
问题 From kernel mode in Windows I'm able to intercept and monitor virtually all actions performed on a particular disk. When a file is opened for any purpose I get an event. Now I want to trace which application that opened it. I think this should be possible but don't know how. I'm using the standard file management functions in Windows Win32 API. Thanks in advance. /Robert 回答1: Just use Win32 N.API to get the pid from the File handle. It's a FAQ for 15 years... 回答2: Sysinternals Filemon (free)

How to run a python script like pm2 for nodejs

不问归期 提交于 2019-11-30 04:48:08
I've used pm2 for my Node.js script and I love it. Now I have a python script which collect streaming data on EC2. Sometimes the script bombs out and I would like a process manager to restart itself like pm2. Is there something the same as pm2 for python? I've been searching around and couldn't find anything. Here's my error File "/usr/local/lib/python2.7/dist-packages/tweepy/streaming.py", line 430, in filter self._start(async) File "/usr/local/lib/python2.7/dist-packages/tweepy/streaming.py", line 346, in _start self._run() File "/usr/local/lib/python2.7/dist-packages/tweepy/streaming.py",

GIT vs. Perforce- Two VCS will enter… one will leave [closed]

ぃ、小莉子 提交于 2019-11-29 19:02:32
So I'm in the process of getting GIT sold at work. First thing I need is to convince everyone that GIT is better at what they're already used to doing. We currently use Perforce. Anybody else go through a similar sale? Any good links/advice? One of the big wins is that we can work with it disconnected from the network. Another win IMO is the way adds/checkouts are handled. More points are welcome! Also we have about 10-20 devs total. The Perl 5 interpreter source code is currently going through the throes of converting from Perforce to git. Maybe Sam Vilain’s git-p4raw importer is of interest.

How do I get rid of Java child processes when my Java app exits/crashes?

淺唱寂寞╮ 提交于 2019-11-29 05:54:11
I launch a child process in Java as follows: final String[] cmd = {"<childProcessName>"}; Process process = Runtime.getRuntime().exec(cmd); It now runs in the background. All good and fine. If my program now crashes (it is still in dev :-)) the child process still seems to hang around. How can I make it automatically end when the parent Java process dies? If it helps, I'm using Mac OS X 10.5 VonC As you said, addShutdownHook is the way to go. BUT: There's no real guarantee that your shutdown hooks are executed if the program terminates. Someone could kill the Java process and in that case your