Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/uu/nice/src/nice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if let Err(e) = rustix::process::setpriority_process(None, new_niceness) {
let warning_msg = translate!("nice-warning-setpriority", "util_name" => "nice", "error" => strip_errno(&e.into()) );

if write!(std::io::stderr(), "{warning_msg}").is_err() {
if writeln!(std::io::stderr(), "{warning_msg}").is_err() {
set_exit_code(125);
return Ok(());
}
Expand Down
11 changes: 5 additions & 6 deletions tests/by-util/test_nice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ fn test_get_current_niceness() {

#[test]
#[cfg(not(target_os = "android"))]
fn test_negative_adj_is_adjustment() {
fn test_nice_adj_negative() {
// This assumes the test suite is run as a normal (non-root) user, and as
// such attempting to set a negative niceness value will be rejected by
// the OS. If it gets denied, then we know a negative value was parsed
// correctly.

let res = new_ucmd!().args(&["--adj", "-1", "true"]).succeeds();
assert!(
res.stderr_str()
.starts_with("nice: warning: setpriority: Permission denied")
); // spell-checker:disable-line
new_ucmd!()
.args(&["--adj", "-20", "true"])
.succeeds()
.stderr_is("nice: warning: setpriority: Permission denied\n");
}

#[test]
Expand Down
Loading