File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
.vscode/cspell.dictionaries Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ LINESIZE
182182NAMESIZE
183183RTLD_NEXT
184184 RTLD
185+ SIGABRT
185186SIGINT
186187SIGKILL
187188SIGSTOP
Original file line number Diff line number Diff line change @@ -748,7 +748,7 @@ impl Error for ClapErrorWrapper {}
748748// This is abuse of the Display trait
749749impl Display for ClapErrorWrapper {
750750 fn fmt ( & self , _f : & mut Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
751- self . error . print ( ) . unwrap ( ) ;
751+ let _ = self . error . print ( ) ;
752752 Ok ( ( ) )
753753 }
754754}
Original file line number Diff line number Diff line change @@ -833,6 +833,37 @@ fn test_child_when_pipe_in() {
833833 ts. ucmd ( ) . pipe_in ( "content" ) . run ( ) . stdout_is ( "content" ) ;
834834}
835835
836+ /// Regression test for GitHub issue #9769
837+ /// https://github.com/uutils/coreutils/issues/9769
838+ ///
839+ /// Bug: Utilities panic when output is redirected to /dev/full
840+ /// Location: src/uucore/src/lib/mods/error.rs:751 - `.unwrap()` causes panic
841+ ///
842+ /// This test verifies that cat handles write errors to /dev/full gracefully
843+ /// instead of panicking with exit code 134 (SIGABRT).
844+ ///
845+ /// Expected behavior with current BUGGY code:
846+ /// - Test WILL FAIL (cat panics with exit code 134)
847+ ///
848+ /// Expected behavior after fix:
849+ /// - Test SHOULD PASS (cat exits gracefully with error code 1)
850+ // Regression test for issue #9769: graceful error handling when writing to /dev/full
851+ #[ test]
852+ #[ cfg( target_os = "linux" ) ]
853+ fn test_write_error_handling ( ) {
854+ use std:: fs:: File ;
855+
856+ let dev_full =
857+ File :: create ( "/dev/full" ) . expect ( "Failed to open /dev/full - test must run on Linux" ) ;
858+
859+ new_ucmd ! ( )
860+ . pipe_in ( "test content that should cause write error to /dev/full" )
861+ . set_stdout ( dev_full)
862+ . fails ( )
863+ . code_is ( 1 )
864+ . stderr_contains ( "No space left on device" ) ;
865+ }
866+
836867#[ test]
837868fn test_cat_eintr_handling ( ) {
838869 // Test that cat properly handles EINTR (ErrorKind::Interrupted) during I/O operations
You can’t perform that action at this time.
0 commit comments