From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753081AbbJNIyE (ORCPT ); Wed, 14 Oct 2015 04:54:04 -0400 Received: from parrot.pmhahn.de ([88.198.50.102]:57711 "EHLO parrot.pmhahn.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752974AbbJNIx7 (ORCPT ); Wed, 14 Oct 2015 04:53:59 -0400 Message-ID: <561E1825.8010500@pmhahn.de> Date: Wed, 14 Oct 2015 10:53:57 +0200 From: Philipp Hahn User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: Re: RFH: stale (f)lock in /proc/locks - process no longer exists References: <561E1293.3050205@pmhahn.de> In-Reply-To: <561E1293.3050205@pmhahn.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To answer my own question: Am 14.10.2015 um 10:30 schrieb Philipp Hahn: > I have several shell scripts using "/usr/bin/flock -x > /run/lock/jenkins-ip.lock" to acquiring the exclusive lock. Today they > hang, while the lock is owned by a process which no longer exists: ... > 1. How can this happen? > My understanding is, that all files are closed on process exit and > that all locks are released then. Did I miss something. I used "{ flock -x 9 } 9<>/var/lock/jenkins-ip.lock": The shell opens the file, but flock runs in a sub-process; after doing the locking the process exits and is no longer available, but the locking for the still opened file persist. My shell script then received some signals, invoked its trap handler, which then did some recursive locking. > 2. How can I release that lock? Killed the recursive "flock -x" call. Philipp