Skip to content

Commit 9931262

Browse files
author
Shukui Yang
committed
Remove the workaround which add a -- flag to runc ps command and add integration for ps -eaf
Signed-off-by: Shukui Yang <[email protected]>
1 parent 650c97a commit 9931262

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

ps.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
var 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",
@@ -47,11 +47,6 @@ var psCommand = cli.Command{
4747
// psArgs: [ps_arg1 ps_arg2 ...]
4848
//
4949
psArgs := context.Args()[1:]
50-
51-
if len(psArgs) > 0 && psArgs[0] == "--" {
52-
psArgs = psArgs[1:]
53-
}
54-
5550
if len(psArgs) == 0 {
5651
psArgs = []string{"-ef"}
5752
}

tests/integration/ps.bats

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bats
2+
3+
load helpers
4+
5+
function setup() {
6+
teardown_busybox
7+
setup_busybox
8+
}
9+
10+
function teardown() {
11+
teardown_busybox
12+
}
13+
14+
@test "ps -eaf" {
15+
# start busybox detached
16+
runc run -d --console /dev/pts/ptmx test_busybox
17+
[ "$status" -eq 0 ]
18+
19+
# check state
20+
wait_for_container 15 1 test_busybox
21+
22+
testcontainer test_busybox running
23+
24+
runc ps test_busybox -eaf
25+
[ "$status" -eq 0 ]
26+
[[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]]
27+
[[ "${lines[1]}" == *"root"*[0-9]* ]]
28+
}

0 commit comments

Comments
 (0)