From patchwork Fri Sep 13 14:21:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 828171 Delivered-To: patch@linaro.org Received: by 2002:adf:a2d0:0:b0:367:895a:4699 with SMTP id t16csp271583wra; Fri, 13 Sep 2024 07:22:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWWOlTIgjRs9NE4R7EmHtTR3ao3ToiuvKfmWsoOehooSXfJ6J7/WZ2R/hJ//ZyvozPwEPfpSQ==@linaro.org X-Google-Smtp-Source: AGHT+IFwNpJRlm/UL+uGmIN3RLA1MPKNAsLNJ4lcTTZuPfB1pGEvQP58POeEVeRPgb4l2MfIM7z+ X-Received: by 2002:a05:6214:449d:b0:6c1:6f54:2930 with SMTP id 6a1803df08f44-6c5735578bbmr107686956d6.12.1726237378716; Fri, 13 Sep 2024 07:22:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1726237378; cv=pass; d=google.com; s=arc-20240605; b=k2YlZBNT9aUehxEfrwFuzPpE+bUYrN1zVTgRB3ZbhYFroiiE18xAKYS4rtC1LX6Um7 JD6+tAw1T/DdnfgYkaRJygrIcHaM8xCOERfnnVcxuqCMCNrUGPFqeh9TZF/YD5jIOLDi 49ZL2V7ItrxVbaRWx9zflmoflMN1xHymMDoHW6++fTrc7NLY1quFbPV5EacWlUEzxCqG I5oA5ghPrci5r7nuLHQxZf8bs+pC3NI4O15Hw3A1Hh2ppezXDDVhaa2MWCjpMtr308YI cHPXFmcPUt2n9EON4gtCEgu+Zr4reXWhJ4S42eUdq+3IOKfIu65nGSBkcYGDP3GXr1Wi Yrww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=WDnTt9osecIJdnZENUJGRARATifZMUGPlHNJ+ZNAly4=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=TlPIOY+Us4sNNKD2vZkodv3/PNnpHO3UpaA8zx8V0Ksxy2yW7HqlB6FewIisUVX794 SQpGVdBQEaJPGfGkEOz1UKVa1T2D5oSHFx1nRuhVAmXZ/GmbXEIFHo+zogK0XgEyy1YC amRRtVfwgpG4OH8XFNYKRT78YJOGilkXcTEVOgmp0ie8w/0Vun5g99hIBcp6/BTrWNWa bt5+6jhPrjEPmaT/MUyy6fN3Xt6/YdzUjvP/8L6Iq57ytVHBJR7e/bvNh9Kgdxaa6A4q 8Rsit9HkMvbhibIYKmug09ee8ALrU9EtIVD7YCNHbWQMmwJ2Hh33krRWS33/gVsl6F9L +1ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3oo7pJn; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 6a1803df08f44-6c5347c343dsi151569826d6.483.2024.09.13.07.22.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 07:22:58 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3oo7pJn; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F31E3858C78 for ; Fri, 13 Sep 2024 14:22:58 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 056063858D28 for ; Fri, 13 Sep 2024 14:22:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 056063858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 056063858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726237367; cv=none; b=sNHRjimNhE1hNk7R2ihHBy+m2kXgfmHZWk4c511XagnOV9g/ASV1hCGzCGA8Ap0C+nrLghfEPfb/2z681ISE4DwGPyfoWwr8vsHNbIi6LbawoNE1f9+6UIu4uCxPfi+X3NPftu84xOSoNd0czkvmeTs1m9DQ7aOauv7nUxDCF50= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726237367; c=relaxed/simple; bh=IjaL6IZl4OCTwvqkqYwpGupdYOp5QzIg2jsZW6Zno1s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e2Y6Vi8LLgTG0jGx0JfiGE4clKD+hU/jr3bIAQQ8TrpnApa+Z201/xeLxLWrf0FS7H/4848v2YCv64fpgcS/D3xHIeuBYsMAThuAugPVqgfwOJSkiktu0Dv+VfJWVPsiQ/uhEvZFMq4Y1UItIfJPXdqRWbUPHt1KcckCOD8H8jE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-6bce380eb96so1379184a12.0 for ; Fri, 13 Sep 2024 07:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726237363; x=1726842163; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=WDnTt9osecIJdnZENUJGRARATifZMUGPlHNJ+ZNAly4=; b=t3oo7pJn43Q+D9AAIgdKDSO5W190pG7rMNx237GBSUof6N2pjdvn4rEssAKS/3+8t+ 06wO5DkHTJ/zgzq7nho0kfQy0xjJNTrXXCLK80fNFTBjbOK5q9ZoMye54XDFx8mFxZxd 85DiYDQDT0BrJGdFUg07aVsCuBAVuJQqSf5H26ry+H/K+5Q6jjaC9CItAg/yvyJrCaxt Md/tC+uvTo8Y2ibD83HgjuPK0hSqnllE2d9HAo3cc9cX5imCRWReYuQIiKNQrkvekvBQ T86DflY3gK/4Vstd9GELMH8WgMBaBBdDT7MJzab+D0VKKCB+Q4ix1LULjnfVf55lhn+V GGLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726237363; x=1726842163; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WDnTt9osecIJdnZENUJGRARATifZMUGPlHNJ+ZNAly4=; b=hg7IKAqCx29koMwCYR2R3iKM3XGDrr2V2lhqNGgWYIU8g4PBJ/gi3eFUP9gpKQ8N1I xwfiOlXNq63X9l6bdJgWFyU3YV/RGxV7ZX13cdV+t5eL86mM+PzTxHWJscNeMSjYfHXY kBTzfFErDczh4W2CzAS4vFxnnFlOcjjNHhSeFcvr6bDC86FPOrSB0zyNl7Z9z0VccIQh SSGtm1Frne/F3nJYKyJnM/plgzrap4qYJf2ePm5tfNTXCoUcOzyYPNk4v3GdbgXyhibj A0ui33H1WNRcRoweP2rXGZFSqP7Ki4zZDUeYh6LtQHV0eWCjhMDKvG0bSPwGLUp305k1 veJg== X-Gm-Message-State: AOJu0YxbIQomKrcPn3Km8cWPig1An0qDWbGbWH4bnL5Nja50KC5L+zxF XW2jSsy+S8/AXiyCwN7sbRHJwhgWBTeM7Ko8ZvTv2ELGbcpnbDWIWAg1YafM8m0Ti4ct25VKgP9 S X-Received: by 2002:a17:90b:1c07:b0:2d3:da82:28e0 with SMTP id 98e67ed59e1d1-2db9ffc1c9fmr6923237a91.9.1726237363195; Fri, 13 Sep 2024 07:22:43 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:80ff:89a7:2ddb:21db:5421]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dbb9c4f447sm1813440a91.6.2024.09.13.07.22.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Sep 2024 07:22:42 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 1/2] support: Make support_process_state_wait return the found state Date: Fri, 13 Sep 2024 11:21:51 -0300 Message-ID: <20240913142239.2949727-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org So caller can check which state was found if multiple ones are asked. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer --- support/process_state.h | 7 +++++-- support/support_process_state.c | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/support/process_state.h b/support/process_state.h index 1cf902e91b..9541d8c343 100644 --- a/support/process_state.h +++ b/support/process_state.h @@ -31,13 +31,16 @@ enum support_process_state support_process_state_dead = 0x20, /* X (dead). */ support_process_state_zombie = 0x40, /* Z (zombie). */ support_process_state_parked = 0x80, /* P (parked). */ + support_process_state_invalid = 0x100 /* Invalid state. */ }; /* Wait for process PID to reach state STATE. It can be a combination of multiple possible states ('process_state_running | process_state_sleeping') where the function return when any of these state are observed. For an invalid state not represented by SUPPORT_PROCESS_STATE, it fallbacks - to a 2 second sleep. */ -void support_process_state_wait (pid_t pid, enum support_process_state state); + to a 2 second sleep. + Return the found process state. */ +enum support_process_state +support_process_state_wait (pid_t pid, enum support_process_state state); #endif diff --git a/support/support_process_state.c b/support/support_process_state.c index 062335234f..ae8e0a531c 100644 --- a/support/support_process_state.c +++ b/support/support_process_state.c @@ -27,7 +27,7 @@ #include #include -void +enum support_process_state support_process_state_wait (pid_t pid, enum support_process_state state) { #ifdef __linux__ @@ -75,7 +75,7 @@ support_process_state_wait (pid_t pid, enum support_process_state state) { free (line); xfclose (fstatus); - return; + return process_states[i].s; } rewind (fstatus); @@ -90,4 +90,6 @@ support_process_state_wait (pid_t pid, enum support_process_state state) /* Fallback to nanosleep if an invalid state is found. */ #endif nanosleep (&(struct timespec) { 1, 0 }, NULL); + + return support_process_state_invalid; }