Skip to content

Commit 58522a7

Browse files
committed
nice -n . 2>/dev/full does not abort
1 parent 23b24c2 commit 58522a7

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/uu/nice/src/nice.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
use clap::{Arg, ArgAction, Command};
99
use libc::PRIO_PROCESS;
1010
use std::ffi::OsString;
11-
use std::io::{Error, ErrorKind, Write, stdout};
11+
use std::io::{Error, ErrorKind, Write, stderr, stdout};
1212
use std::num::IntErrorKind;
1313
use std::os::unix::process::CommandExt;
1414
use std::process;
1515

1616
use uucore::translate;
1717
use uucore::{
18-
error::{UResult, USimpleError, UUsageError, set_exit_code},
18+
error::{UResult, USimpleError, set_exit_code},
1919
format_usage, show_error,
2020
};
2121

@@ -121,10 +121,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
121121

122122
let adjustment = if let Some(nstr) = matches.get_one::<String>(options::ADJUSTMENT) {
123123
if !matches.contains_id(options::COMMAND) {
124-
return Err(UUsageError::new(
125-
125,
126-
translate!("nice-error-command-required-with-adjustment"),
127-
));
124+
let _ = writeln!(
125+
stderr(),
126+
"nice: {}",
127+
translate!("nice-error-command-required-with-adjustment")
128+
);
129+
set_exit_code(125);
130+
return Ok(());
128131
}
129132
match nstr.parse::<i32>() {
130133
Ok(num) => num,
@@ -155,7 +158,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
155158
if unsafe { libc::setpriority(PRIO_PROCESS, 0, niceness) } == -1 {
156159
let warning_msg = translate!("nice-warning-setpriority", "util_name" => uucore::util_name(), "error" => Error::last_os_error());
157160

158-
if write!(std::io::stderr(), "{warning_msg}").is_err() {
161+
if write!(stderr(), "{warning_msg}").is_err() {
159162
set_exit_code(125);
160163
return Ok(());
161164
}

0 commit comments

Comments
 (0)