]> git.tuebingen.mpg.de Git - dss.git/commit - dss.c
Add the --kill subcommand.
authorAndre Noll <maan@systemlinux.org>
Sat, 13 Nov 2010 19:51:28 +0000 (20:51 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 1 Jun 2012 15:31:36 +0000 (17:31 +0200)
commit492928ebe8b83c31aeca4866fef37ab07174ed9c
tree9cd8f8d22080ceab28843501f9b411fc98af1aa8
parentdd42f745333f7273a1ef1e81b090705473de8079
Add the --kill subcommand.

It works as follows: Whenever a semaphore operation is performed, the
PID of the process is stored in the sempid field of the semaphore.
This PID can be obtained from a different process by calling semctl
with the GETPID command.

com_kill() first tries to acquire the lock by calling the new
mutex_try_lock() function of ipc.c. In contrast to mutex_lock(),
mutex_try_lock() only operates on the first semaphore in the semaphore
set, leaving the sempid field of the second semaphore unchanged. If
mutex_try_lock() succeeds, no running dss process is holding the lock
and the kill command fails. Otherwise, some dss process is running
whose PID can be obtained by calling semctl() on the second semaphore.
dss.c
dss.ggo
error.h
ipc.c
ipc.h