Skip to content

setpgid: accept a command and arguments that are not valid UTF-8 - #655

Merged
sylvestre merged 1 commit into
uutils:mainfrom
SichenLiang:setpgid-non-utf8-args
Oct 5, 2026
Merged

sylvestre merged 1 commit into
uutils:mainfrom
SichenLiang:setpgid-non-utf8-args

Conversation

@SichenLiang

Copy link
Copy Markdown
Contributor

Read the program name and its arguments as OsString so they reach execvp() unchanged. This allows both non-UTF-8 arguments and program paths, matching util-linux 2.42.4.

If execvp() fails, the diagnostic still displays the program name with to_string_lossy(), as setsid does.

The Unix tests cover a non-UTF-8 argument and, on Linux, a command run through a symlink whose name contains byte ff.

Fixes #654

Comment thread tests/by-util/test_setpgid.rs Outdated
}

#[test]
#[cfg(target_os = "linux")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only linux? /bin/sh should be there on every unix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/bin/sh is available on macOS, but the test cannot create the link there. APFS rejects a link name containing invalid UTF-8, and symlink fails with Illegal byte sequence.
I changed the condition to #[cfg(all(unix, not(target_os = "macos")))], as in test_last.rs, so the test now runs on the other Unix targets instead of Linux only.

Read the command and its arguments as OsString so they reach execvp()
unchanged, as they do with util-linux setpgid.
@SichenLiang
SichenLiang force-pushed the setpgid-non-utf8-args branch from 56fa700 to 0553e25 Compare October 5, 2026 03:17
@sylvestre
sylvestre merged commit d5845d6 into uutils:main Oct 5, 2026
14 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setpgid: a program name or argument that is not valid UTF-8 is rejected

2 participants