From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by sourceware.org (Postfix) with ESMTPS id BE975385771D for ; Tue, 2 May 2023 16:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE975385771D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-559f1819c5dso46594167b3.0 for ; Tue, 02 May 2023 09:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683044378; x=1685636378; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=55QEgALDyodK3LnT2uaR4zR/iQfCLC+0ly/FjvTg7gA=; b=nQbapLMQbFx5KjJH1hGPKdvddsIxW5KhwKuYIFD6RKU2ZmPSkdZcOqrMGIEVQOX8/v 2Y1Pt1jqeYuuxvXUWyhxctahtkc8Q3k4VlrlH/VGmIG9DMW8iPBKWGRU7FmSzuyXzjpB /yLYfF643bjE42hE5iiSkKgy2fQwYSYaLZ8N90KwI7P/U0LszEaIGq3uyymDqDJdW6xL Cpo0C241v0M0L4yWpEHvUcyoLOsns3YF6iR0a2QhTIx/yKpGEINQeh3nWg6y7LcryWFG txRCPfP5KdLlOlunvPEeFvakddB0k4+yO95NdPR4gTsw3bK/erukztwXiSb9xvlRbdvb iduw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683044378; x=1685636378; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=55QEgALDyodK3LnT2uaR4zR/iQfCLC+0ly/FjvTg7gA=; b=HSYc8WbeKRrNzpCBDQqLt7UI6VmLdO3eFUSR6nEFvEV6ZpePFIjxEz7Pi2UIb4j3wS 0K5NIXWyokvOFhACGrXC3BrIUABi5NP+2HH/F+HBWKKXW9SAGvu+EGYh9jnlTN9bdvuT A22MpNqqtyJW4bZA1pkUBAwwUN7u5bz5N2ifd5gklsqYuKaEwnajBMat7ITUuTPZiewP Ahnttg2UjWRFicq3b9vtAEqIRlCm95g7gPLLIZKlAghLdx6N2/oehe7pLZE4R2pW7MV9 H9yzxjNRb8v9IcTP96h/f58Cb5t53BDUi3GV661KSAE3KkKizX7cJUDqNe0LlH6SRTj6 ODsw== X-Gm-Message-State: AC+VfDyEUtiTec0za4cl6vghHcmOym3ykKDU4WOwqwD5RUapga+xL2pY YxZ2Gu+267bqSgbYkssIPNPONtGiZTEWV6QZIUg= X-Google-Smtp-Source: ACHHUZ54kmaM/ax9phew2YfcQJVQvPb+xZyhtH/NSadtTDWEjyWrQu5jyEGriq7GZ10K35tXVP8pIEHkWvMKej9+9xY= X-Received: by 2002:a0d:db45:0:b0:55a:4164:74fd with SMTP id d66-20020a0ddb45000000b0055a416474fdmr8397043ywe.33.1683044378120; Tue, 02 May 2023 09:19:38 -0700 (PDT) MIME-Version: 1.0 References: <20230420142037.4063169-1-adhemerval.zanella@linaro.org> <20230420142037.4063169-4-adhemerval.zanella@linaro.org> <87r0rysomw.fsf@oldenburg.str.redhat.com> In-Reply-To: <87r0rysomw.fsf@oldenburg.str.redhat.com> From: Luca Boccassi Date: Tue, 2 May 2023 17:19:26 +0100 Message-ID: Subject: Re: [PATCH v2 3/3] linux: Add pidfd_getpid To: Florian Weimer Cc: Adhemerval Zanella via Libc-alpha , Adhemerval Zanella Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 2 May 2023 at 17:07, Florian Weimer wrote: > > * Adhemerval Zanella via Libc-alpha: > > diff --git a/sysdeps/unix/sysv/linux/pidfd_getpid.c b/sysdeps/unix/sysv/linux/pidfd_getpid.c > > new file mode 100644 > > index 0000000000..d0c7987791 > > --- /dev/null > > +++ b/sysdeps/unix/sysv/linux/pidfd_getpid.c > > @@ -0,0 +1,94 @@ > > > +static bool > > +parse_fdinfo (const char *l, void *arg) > > +{ > > + enum { fieldlen = sizeof ("Pid:") - 1 }; > > + if (strncmp (l, "Pid:", fieldlen) != 0) > > + return true; > > + > > + l += fieldlen; > > + > > + char *endp; > > + long int n = strtol (l, &endp, 10); > > + if (l == endp || n > INT_MAX) > > + return true; > > Should this use strtoul? Otherwise I'm not sure the overflow check will > work on 32-bit. > > Rest of the implementation looks okay, but the kernel should really > provide an ioctl or similar for this. This can be -1 when the process is gone, and it is important to get that distinction (with certainty) to tell the caller ESRCH. We need this distinction in callers. Kind regards, Luca Boccassi