File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 22 runc ps - ps displays the processes running inside a container
33
44# SYNOPSIS
5- runc ps [ command options] <container-id > [ ps options]
5+ runc ps [ command options] <container-id > [ -- ps options]
66
77# OPTIONS
88 --format value, -f value select one of: table(default) or json
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ import (
1616var psCommand = cli.Command {
1717 Name : "ps" ,
1818 Usage : "ps displays the processes running inside a container" ,
19- ArgsUsage : `<container-id> [ps options]` ,
19+ ArgsUsage : `<container-id> [-- ps options]` ,
2020 Flags : []cli.Flag {
2121 cli.StringFlag {
2222 Name : "format, f" ,
@@ -42,12 +42,21 @@ var psCommand = cli.Command{
4242 return nil
4343 }
4444
45- psArgs := context .Args ().Get (1 )
46- if psArgs == "" {
47- psArgs = "-ef"
45+ // [1:] is to remove command name, ex:
46+ // context.Args(): [containet_id ps_arg1 ps_arg2 ...]
47+ // psArgs: [ps_arg1 ps_arg2 ...]
48+ //
49+ psArgs := context .Args ()[1 :]
50+
51+ if len (psArgs ) > 0 && psArgs [0 ] == "--" {
52+ psArgs = psArgs [1 :]
53+ }
54+
55+ if len (psArgs ) == 0 {
56+ psArgs = []string {"-ef" }
4857 }
4958
50- output , err := exec .Command ("ps" , strings . Split ( psArgs , " " ) ... ).Output ()
59+ output , err := exec .Command ("ps" , psArgs ... ).Output ()
5160 if err != nil {
5261 return err
5362 }
You can’t perform that action at this time.
0 commit comments