From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5457 invoked from network); 14 Jun 2022 10:16:03 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 14 Jun 2022 10:16:03 -0000 Received: (qmail 28665 invoked by uid 550); 14 Jun 2022 10:15:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 28627 invoked from network); 14 Jun 2022 10:15:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ndmsystems.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=+6F+UJoceoFYZmtnLP0Hfr1y3/vBiu6XZ9IrvSd4wHE=; b=Bi27O+S+A+MdiDqNExTXOCOjaqUdw8c6qewFlGmajMcLZ312URCa4LtxbebA2GJt1T AFayLdXl2Bjku0Q+cQz5wsHpfXB/milegk3ncvkNl7E7LE3wKknYh/KOnmswHbRfrLUb g1mW4m5nmAum6wpRdB80iNvpqA/H5+bupZnCA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+6F+UJoceoFYZmtnLP0Hfr1y3/vBiu6XZ9IrvSd4wHE=; b=Dh2CJaLooSpE4UcGA962MqWLbhM7+2cOSfJ2p1ZFQOe3DTOxag8Bxlg9ZbJgUpwDGx HYsJPm9gjLwRbBprQ69F8MgdKn910+CEcfIl5clXGl2uSELjrcmxTLNdSvGvKGI8vc1h hsKYFNpbkuZIqnerPekVH3spnS7OfYyWHOF62hqYLfSgRdKe3Kt6SBUbJuJTvxTFud7A ABtFwGYhLPhA90wGHsjbI6+kbkOO81QY4zCO5xUyFZjg9NiGRZljkodV+kO/Xtlu8K88 CVmmHABPFIunwyeQLPeE/2a4eLUWTETtzMRwuORHS0H5h1bb1tPWc5fcoAJyKkkCg7SF AclA== X-Gm-Message-State: AJIora/arWtqDY25KRzPW7vbKVSzAO2t60tL4zLtNHVasnEcfI/J6u/3 K8S0kg/V/egC5wMWGYqbdlW8GAWUbnp9f0nDqriJf951z4Qwgw== X-Google-Smtp-Source: AGRyM1uIoKB9xkn9+TaJon02k8Ic4DyebkJiP+Lpr1M5cbZeu3AobasHhfuIsqRm5iCF7UdYwczdpJWFTlKJQI9ehBc= X-Received: by 2002:a05:6214:c68:b0:464:6460:8211 with SMTP id t8-20020a0562140c6800b0046464608211mr2911530qvj.16.1655201747014; Tue, 14 Jun 2022 03:15:47 -0700 (PDT) MIME-Version: 1.0 From: Eugene Yudin Date: Tue, 14 Jun 2022 13:15:36 +0300 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="00000000000029aaee05e165b006" Subject: [musl][PATCH] make clock_getcpuclockid return ESRCH rather than EINVAL --00000000000029aaee05e165b006 Content-Type: text/plain; charset="UTF-8" Hi, According to man clock_getcpuclockid() should return ESRCH if there is no process with the ID pid. diff --git a/src/time/clock_getcpuclockid.c b/src/time/clock_getcpuclockid.c --- a/src/time/clock_getcpuclockid.c +++ b/src/time/clock_getcpuclockid.c @@ -8,6 +8,7 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clk) struct timespec ts; clockid_t id = (-pid-1)*8U + 2; int ret = __syscall(SYS_clock_getres, id, &ts); + if (ret == -EINVAL) ret = -ESRCH; if (ret) return -ret; *clk = id; return 0 The same behaviour is used in glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/clock_getcpuclockid.c;h=5534127ed703a3931f22af48da02e2b8f2dc39a5;hb=HEAD#l49 -- Best regards, Eugene --00000000000029aaee05e165b006 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

According to man clock_getcpuclockid() should r= eturn ESRCH if there is no process with the ID pid.

diff --git a/src= /time/clock_getcpuclockid.c b/src/time/clock_getcpuclockid.c
--- a/src/t= ime/clock_getcpuclockid.c
+++ b/src/time/clock_getcpuclockid.c
@@ -8,= 6 +8,7 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clk)
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 struct timespec ts;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 clocki= d_t id =3D (-pid-1)*8U + 2;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int ret =3D __sy= scall(SYS_clock_getres, id, &ts);
+ =C2=A0 =C2=A0 =C2=A0 if (ret =3D= =3D -EINVAL) ret =3D -ESRCH;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ret) return= -ret;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 *clk =3D id;
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 return 0


--
Best regards,
Eugene
--00000000000029aaee05e165b006--