mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
Remove the workaround which add a -- flag to runc ps command and add integration for ps -eaf
Signed-off-by: Shukui Yang <yangshukui@huawei.com>
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
var psCommand = cli.Command{
|
||||
Name: "ps",
|
||||
Usage: "ps displays the processes running inside a container",
|
||||
ArgsUsage: `<container-id> [-- ps options]`,
|
||||
ArgsUsage: `<container-id> [ps options]`,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "format, f",
|
||||
@@ -47,11 +47,6 @@ var psCommand = cli.Command{
|
||||
// psArgs: [ps_arg1 ps_arg2 ...]
|
||||
//
|
||||
psArgs := context.Args()[1:]
|
||||
|
||||
if len(psArgs) > 0 && psArgs[0] == "--" {
|
||||
psArgs = psArgs[1:]
|
||||
}
|
||||
|
||||
if len(psArgs) == 0 {
|
||||
psArgs = []string{"-ef"}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers
|
||||
|
||||
function setup() {
|
||||
teardown_busybox
|
||||
setup_busybox
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
teardown_busybox
|
||||
}
|
||||
|
||||
@test "ps -eaf" {
|
||||
# start busybox detached
|
||||
runc run -d --console /dev/pts/ptmx test_busybox
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# check state
|
||||
wait_for_container 15 1 test_busybox
|
||||
|
||||
testcontainer test_busybox running
|
||||
|
||||
runc ps test_busybox -eaf
|
||||
[ "$status" -eq 0 ]
|
||||
[[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]]
|
||||
[[ "${lines[1]}" == *"root"*[0-9]* ]]
|
||||
}
|
||||
Reference in New Issue
Block a user