From patchwork Mon Oct 14 21:35:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1176657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510957-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Vs3ZHCM8"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="VsisM/3p"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46sX1J0rpfz9s4Y for ; Tue, 15 Oct 2019 08:36:03 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding; q=dns; s=default; b=ye9qtlHHmvIr0nJa rVAdyXkfwojdB+lEb33+QTynEOjs4i1+asgvtVH/2KTEQdB1t77Ak5w1YUVK1+qK NRWUQErTS3OytIRmLmx/qjLo4C9m5QsJ+xSg4XetUm7PTuZTPKtLQWilkycptqBp HybDrv0EOdmAqnNOuMw9b8BYlhk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding; s=default; bh=SHJzyY+vHWxn4fJQPFhphU SD4Fk=; b=Vs3ZHCM8SnCshrLbWnYw6Urev/+/qmil1uUCHwyq6HeaBjfRByR9/f +0sSFk3hpZKmFhjaWg/DO9kRoj2L9+0R9CjB5VhtfNVfhn+eGQAtMUVd/RnLqG+Z oiZLcxorIAQKZaLjiHZtADz7F5GuyVhKd6+sRGBwZRfJJ/AjTrTlQ= Received: (qmail 113953 invoked by alias); 14 Oct 2019 21:35:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 113939 invoked by uid 89); 14 Oct 2019 21:35:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=powerful, HX-Languages-Length:1761 X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Oct 2019 21:35:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571088953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6BLlpJIHyA2SyFszMpa2GYQ5+MdvJf9pqeJdCHKiPjI=; b=VsisM/3p1NR4D2BSaIHMJvPZoX/evwfjfmsbP3/W69jUTfnJZ1vXE75/0yFgM/i0jPhBDN eiBQ/E2SjOx/MvX+CdbWDfMp17fWvh8TDbcWwi0IL/uAAS4VcF011CGNK5ojYlazIVGxVi x8fHEH1B+j5FpBL39nxaZqzD5iM4M7s= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-WF2ddXWnOrSSiAhl-J93SQ-1; Mon, 14 Oct 2019 17:35:50 -0400 Received: by mail-io1-f69.google.com with SMTP id e14so28685665iot.16 for ; Mon, 14 Oct 2019 14:35:50 -0700 (PDT) Received: from jason.com (209-6-216-142.s141.c3-0.smr-cbr1.sbo-smr.ma.cable.rcncustomer.com. [209.6.216.142]) by smtp.gmail.com with ESMTPSA id d27sm1877849ill.64.2019.10.14.14.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 14:35:48 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Cc: oliva@gnu.org Subject: RFA [PATCH] * lock-and-run.sh: Check for process existence rather than timeout. Date: Mon, 14 Oct 2019 17:35:45 -0400 Message-Id: <20191014213545.24627-1-jason@redhat.com> X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes Matthias Klose noted that on less powerful targets, a link might take more than 5 minutes; he mentions a figure of 3 hours for an LTO link. So this patch changes the timeout to a check for whether the locking process still exists. Alex, you had a lot of helpful comments when I first wrote this, any thoughts on this revision? --- gcc/lock-and-run.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) base-commit: aa45db50a034b266c338b55dee1b412178ea84a7 diff --git a/gcc/lock-and-run.sh b/gcc/lock-and-run.sh index 3a6a84c253a..404350b89a4 100644 --- a/gcc/lock-and-run.sh +++ b/gcc/lock-and-run.sh @@ -5,29 +5,28 @@ lockdir="$1" prog="$2"; shift 2 || exit 1 # Remember when we started trying to acquire the lock. count=0 -touch lock-stamp.$$ -trap 'rm -r "$lockdir" lock-stamp.$$' 0 +trap 'rm -rf "$lockdir"' 0 until mkdir "$lockdir" 2>/dev/null; do # Say something periodically so the user knows what's up. if [ `expr $count % 30` = 0 ]; then - # Reset if the lock has been renewed. - if [ -n "`find \"$lockdir\" -newer lock-stamp.$$`" ]; then - touch lock-stamp.$$ - count=1 - # Steal the lock after 5 minutes. - elif [ $count = 300 ]; then - echo removing stale $lockdir >&2 - rm -r "$lockdir" + # Check for stale lock. + pid="`(cd $lockdir; echo *)`" + if ps "$pid" >/dev/null; then + echo PID $$ waiting $count sec to acquire $lockdir from PID $pid>&2 + found=$pid else - echo waiting to acquire $lockdir >&2 + echo PID $pid is dead, removing stale $lockdir >&2 + rm -r "$lockdir" fi fi sleep 1 count=`expr $count + 1` done +touch $lockdir/$$ +echo PID $$ acquired $lockdir after $count seconds >&2 echo $prog "$@" $prog "$@"