File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 11// SPDX-FileCopyrightText: Copyright © 2020-2024 Serpent OS Developers
22//
33// SPDX-License-Identifier: MPL-2.0
4- use std :: env :: set_current_dir ;
4+
55use std:: io;
66use std:: os:: fd:: AsRawFd ;
77use std:: path:: { Path , PathBuf } ;
@@ -358,6 +358,26 @@ fn add_mount<T: AsRef<Path>>(
358358 Ok ( ( ) )
359359}
360360
361+ fn set_current_dir ( path : impl AsRef < Path > ) -> io:: Result < ( ) > {
362+ #[ derive( Debug , Error ) ]
363+ #[ error( "failed to set current directory to `{}`" , path. display( ) ) ]
364+ struct SetCurrentDirError {
365+ source : io:: Error ,
366+ path : PathBuf ,
367+ }
368+
369+ let path = path. as_ref ( ) ;
370+ std:: env:: set_current_dir ( path) . map_err ( |source| {
371+ io:: Error :: new (
372+ source. kind ( ) ,
373+ SetCurrentDirError {
374+ source,
375+ path : path. to_owned ( ) ,
376+ } ,
377+ )
378+ } )
379+ }
380+
361381fn ignore_sigint ( ) -> Result < ( ) , nix:: Error > {
362382 let action = SigAction :: new ( SigHandler :: SigIgn , SaFlags :: empty ( ) , SigSet :: empty ( ) ) ;
363383 unsafe { sigaction ( Signal :: SIGINT , & action) ? } ;
You can’t perform that action at this time.
0 commit comments