@@ -26,6 +26,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2626 let matches = uu_app ( ) . try_get_matches_from ( args) ?;
2727 #[ cfg( target_os = "linux" ) ]
2828 {
29+ if matches. get_flag ( "forks" ) {
30+ return print_forks ( ) ;
31+ }
2932 if matches. get_flag ( "stats" ) {
3033 return print_stats ( ) ;
3134 }
@@ -83,6 +86,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
8386 Ok ( ( ) )
8487}
8588
89+ #[ cfg( target_os = "linux" ) ]
90+ fn print_forks ( ) -> UResult < ( ) > {
91+ let data = get_stats ( ) ;
92+
93+ let fork_data = data. last ( ) . unwrap ( ) ;
94+ println ! ( "{:>13} {}" , fork_data. 1 , fork_data. 0 ) ;
95+
96+ Ok ( ( ) )
97+ }
98+
8699#[ cfg( target_os = "linux" ) ]
87100fn print_stats ( ) -> UResult < ( ) > {
88101 let data = get_stats ( ) ;
@@ -177,10 +190,13 @@ pub fn uu_app() -> Command {
177190 . required ( false )
178191 . value_parser ( value_parser ! ( u64 ) ) ,
179192 arg ! ( -a --active "Display active and inactive memory" ) ,
180- // arg!(-f --forks "switch displays the number of forks since boot"),
181- arg ! ( -m --slabs "Display slabinfo" ) ,
193+ arg ! ( -f --forks "switch displays the number of forks since boot" )
194+ . conflicts_with_all ( [ "slabs" , "stats" , /*"disk", "disk-sum", "partition"*/ ] ) ,
195+ arg ! ( -m --slabs "Display slabinfo" )
196+ . conflicts_with_all ( [ "forks" , "stats" , /*"disk", "disk-sum", "partition"*/ ] ) ,
182197 arg ! ( -n --"one-header" "Display the header only once rather than periodically" ) ,
183- arg ! ( -s --stats "Displays a table of various event counters and memory statistics" ) ,
198+ arg ! ( -s --stats "Displays a table of various event counters and memory statistics" )
199+ . conflicts_with_all ( [ "forks" , "slabs" , /*"disk", "disk-sum", "partition"*/ ] ) ,
184200 // arg!(-d --disk "Report disk statistics"),
185201 // arg!(-D --"disk-sum" "Report some summary statistics about disk activity"),
186202 // arg!(-p --partition <device> "Detailed statistics about partition"),
0 commit comments