1

What is the impact of killing a process on the operating system (Windows and Linux)?

I have a script that forks some executables and monitors their progress and kill those that exceed certain runtime limit. I wanted to know if killing processes would cause issues to the OS

| |
3

It depends on what these processes are and what they are doing.

At the most basic level, the kernel is designed to cope with user-mode processes dying unexpectedly (with one or two exceptions: for instance, Linux has special-case code to force a system crash if init ever terminates; probably there is at least one such extra-special process on Windows; but you are probably not writing those programs). It automatically closes all the files the process had open, deallocates memory, releases locks, etc. So you do not need to worry about the fundamental stability of the OS being disrupted.

Now, it gets more interesting if the process in question writes stuff to the file system or communicates with other processes (perhaps not even on the same computer). Communications peers will receive a sudden EOF, a TCP RST, or something similar. Files will persist, possibly with internally inconsistent contents, and something might trip over them. Ultimately it is your responsibility to make sure that everything else on the system is prepared to cope with your process going away.

Read up on crash-only design for how to build systems that are robust in the presence of resource limit enforcers and similar.

| |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.