/rescue/pgrep fails to recognize the -q option. When run without any options, it prints the usage message for pkill. Debugging with lldb shows that the call to getprogname() is actually calling getexecname() from sys/contrib/openzfs/lib/libspl/os/freebsd/getexecname.c, which does not trim the leading path from the executable name, resulting in "if (strcmp(_getprogname(), "pgrep") == 0) {" not matching, and the executable behaving as pkill instead of pgrep.
I submitted a patch on Phabricator: https://reviews.freebsd.org/D38716
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=7f0ebf0876c82a098bd5815ea6bf3a8efa6dd6f3 commit 7f0ebf0876c82a098bd5815ea6bf3a8efa6dd6f3 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2023-02-23 18:00:09 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2023-02-23 18:00:09 +0000 Delete obsolete Solaris compat header file stdlib.h This drops function `getexecname()` redirection. Historically `getexecname()` is a compatibility definition. Since openzfs has its own implementation of function `getexecname()` in libspl and has been merged into base, the compat header file stdlib.h is no longer needed and should not be used. Also without this fix libspl will end up an incompatible version of `getprogname()` with libc. In particular, if zfs is enabled, programs such as pgrep in /rescue can be wrongly statically linked with libspl and will not function properly. PR: 269738 Reviewed by: markj Fixes: 9e5787d2284e Merge OpenZFS support in to HEAD MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38733 cddl/compat/opensolaris/include/stdlib.h (gone) | 37 ------------------------- 1 file changed, 37 deletions(-)
I cherry-picked 7f0ebf08 into a 13.1 repo, and got this error: ld: error: undefined symbol: getexecname >>> referenced by utils.c:50 (/space/jenkins/customws/13.1_Sandbox/amd64/ports/REDCOM-src/fbsd_base/cddl/contrib/opensolaris/tools/ctf/common/utils.c:50) >>> utils.o:(getpname) Is this change suitable only for head, and not 13?
(In reply to Stephen Wall from comment #3) You also want 3dd5524264095ed8612c28908e13f80668eff2f9.
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=95f418fe2a0fb96080afbd2afc160929a32d12fb commit 95f418fe2a0fb96080afbd2afc160929a32d12fb Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2023-02-23 18:00:09 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2023-03-02 02:56:05 +0000 Delete obsolete Solaris compat header file stdlib.h This drops function `getexecname()` redirection. Historically `getexecname()` is a compatibility definition. Since openzfs has its own implementation of function `getexecname()` in libspl and has been merged into base, the compat header file stdlib.h is no longer needed and should not be used. Also without this fix libspl will end up an incompatible version of `getprogname()` with libc. In particular, if zfs is enabled, programs such as pgrep in /rescue can be wrongly statically linked with libspl and will not function properly. PR: 269738 Reviewed by: markj Fixes: 9e5787d2284e Merge OpenZFS support in to HEAD MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38733 (cherry picked from commit 7f0ebf0876c82a098bd5815ea6bf3a8efa6dd6f3) cddl/compat/opensolaris/include/stdlib.h (gone) | 37 ------------------------- 1 file changed, 37 deletions(-)
A commit in branch releng/13.2 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=b4eb5f81eead115fe49e349a933c72046158b930 commit b4eb5f81eead115fe49e349a933c72046158b930 Author: Zhenlei Huang <zlei@FreeBSD.org> AuthorDate: 2023-02-23 18:00:09 +0000 Commit: Zhenlei Huang <zlei@FreeBSD.org> CommitDate: 2023-03-02 08:22:26 +0000 Delete obsolete Solaris compat header file stdlib.h This drops function `getexecname()` redirection. Historically `getexecname()` is a compatibility definition. Since openzfs has its own implementation of function `getexecname()` in libspl and has been merged into base, the compat header file stdlib.h is no longer needed and should not be used. Also without this fix libspl will end up an incompatible version of `getprogname()` with libc. In particular, if zfs is enabled, programs such as pgrep in /rescue can be wrongly statically linked with libspl and will not function properly. PR: 269738 Reviewed by: markj Approved by: re (delphij) Fixes: 9e5787d2284e Merge OpenZFS support in to HEAD MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38733 (cherry picked from commit 7f0ebf0876c82a098bd5815ea6bf3a8efa6dd6f3) (cherry picked from commit 95f418fe2a0fb96080afbd2afc160929a32d12fb) cddl/compat/opensolaris/include/stdlib.h (gone) | 37 ------------------------- 1 file changed, 37 deletions(-)
The fix will be in upcoming release 13.2-RC1. Thanks for the report!
*** Bug 269864 has been marked as a duplicate of this bug. ***