Kill a hanged disk i/o process...

Nikos Vassiliadis nvass at teledomenet.gr
Fri Mar 9 09:38:36 UTC 2007


On Thursday 08 March 2007 13:49, Modulok wrote:
> To the best of my knowledge, most processes can be killed explicitly
> by "kill -s KILL;" There are a few which cannot, such as disk i/o
> processes. The idea here is data integrity.

A process might be in cannot-be-killed condition while
in kernel e.g. during a system call. That has to do with
the completion of the system call, not with data integrity.
The kernel tries to complete what was asked for.

Also, Killing a process with SIGKILL is far from safe. To put
it in another way "data integrity" can be guaranteed only
by the program itself. For example it could have a defined
behavior when it is signaled by e.g. SIGTERM, for example
clean up data and exit. Or not. It's up to the programmer.
Sending a SIGKILL will not give that chance. SIGKILL can
not be handled. It will be terminated as soon as possible.

Also, separate the meanings "data integrity" and "filesystem
data integrity". The filesystem will be in fine condition when
a process gets killed by SIGKILL during file I/O, the data in
the file most probably not.

> 
> On the rare occasion however, (when attempting to recover data from
> corrupt disks for example), I've had a process invoked by the "cp"
> command, hang. This poses a significant problem as these processes are
> disk i/o processes, and as such cannot be terminated (even by root).
> So, other than physically hitting the reset button on the case, is
> there a more eloquent method of forcefully halting a hanged disk i/o
> process? The idea of "you don't want to terminate a disk i/o process,
> it could corrupt the data" isn't really a good argument, because if
> the process hangs and I have to punch the reset button anyway what's
> the difference?

"Pressing the button" will leave your filesystem in a undefined state,
you are risking filesystem integrity. Keep in mind that while in use
(open files etc) a filesystem cannot be unmounted. Anyway, try to shut
the computer down, it's far more gentle than pressing the button. At
least the rest of the filesystems will be cleanly unmounted.

Is there something in particular you want to achieve?

Nikos


More information about the freebsd-questions mailing list