On Sat, Sep 13, 2025 at 09:55:52PM +0300, Gleb Popov wrote: > This change affects following code inside the Qt library: > https://github.com/qt/qtbase/blob/d6cc7562689d8a07bc933178ea367706ca38e4ac/src/3rdparty/forkfd/forkfd.c#L902 > > The code in question expects to receive EBADF when being fed a wrong > type of the descriptor. Returning EINVAL makes sense to me, so maybe > we should patch Qt rather than revert this change?
It is really weird code, calling pdgetpid(2) on random fds. Anyway, please confirm that the following revert makes the problem go away. BTW, would it be useful to implement something like waitid(P_PROCDESC) to eliminate the ugly code you pointed to? commit 4b47521ce2bc4ede52611c268d00ceb1608d959e Author: Konstantin Belousov <k...@freebsd.org> Date: Sat Sep 13 22:23:27 2025 +0300 pdgetpid(2): switch back returning EBADF for non-procdesc fd This partially reverts fd9e09cb2ab0, since apparently QT depends on this specific error code. It seems that it applies pdgetpid() to random fds and filters non-procdescs by checking errno for EBADF. Reported by: gleb Sponsored by: The FreeBSD Foundation MFC after: 1 week diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index 54b03fc82c90..acaf1241cb2e 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -175,7 +175,7 @@ kern_pdgetpid(struct thread *td, int fd, const cap_rights_t *rightsp, if (error) return (error); if (fp->f_type != DTYPE_PROCDESC) { - error = EINVAL; + error = EBADF; goto out; } *pidp = procdesc_pid(fp);