mirror of
https://github.com/DominicBreuker/pspy.git
synced 2025-12-21 03:34:50 +00:00
Increase width of uid field from 4 chars to 5 to allow for range of 16-bit uids.
This commit is contained in:
@@ -26,11 +26,11 @@ func (evt PSEvent) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if evt.PPID == -1 {
|
if evt.PPID == -1 {
|
||||||
return fmt.Sprintf("UID=%-4s PID=%-6d | %s", uid, evt.PID, evt.CMD)
|
return fmt.Sprintf("UID=%-5s PID=%-6d | %s", uid, evt.PID, evt.CMD)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"UID=%-4s PID=%-6d PPID=%-6d | %s", uid, evt.PID, evt.PPID, evt.CMD)
|
"UID=%-5s PID=%-6d PPID=%-6d | %s", uid, evt.PID, evt.PPID, evt.CMD)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPSScanner(ppid bool) *PSScanner {
|
func NewPSScanner(ppid bool) *PSScanner {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ func TestRun(t *testing.T) {
|
|||||||
events []string
|
events []string
|
||||||
}{
|
}{
|
||||||
{pids: []int{1, 2, 3}, events: []string{
|
{pids: []int{1, 2, 3}, events: []string{
|
||||||
"UID=??? PID=3 | the-command",
|
"UID=??? PID=3 | the-command",
|
||||||
"UID=??? PID=2 | the-command",
|
"UID=??? PID=2 | the-command",
|
||||||
"UID=??? PID=1 | the-command",
|
"UID=??? PID=1 | the-command",
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ func TestPSEvent(t *testing.T) {
|
|||||||
pid: 123,
|
pid: 123,
|
||||||
ppid: 321,
|
ppid: 321,
|
||||||
cmd: "some cmd",
|
cmd: "some cmd",
|
||||||
expected: "UID=999 PID=123 PPID=321 | some cmd",
|
expected: "UID=999 PID=123 PPID=321 | some cmd",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "nominal-without-ppid",
|
name: "nominal-without-ppid",
|
||||||
@@ -431,7 +431,7 @@ func TestPSEvent(t *testing.T) {
|
|||||||
pid: 123,
|
pid: 123,
|
||||||
ppid: -1,
|
ppid: -1,
|
||||||
cmd: "some cmd",
|
cmd: "some cmd",
|
||||||
expected: "UID=999 PID=123 | some cmd",
|
expected: "UID=999 PID=123 | some cmd",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "nocmd-without-ppid",
|
name: "nocmd-without-ppid",
|
||||||
@@ -439,7 +439,7 @@ func TestPSEvent(t *testing.T) {
|
|||||||
pid: 123,
|
pid: 123,
|
||||||
ppid: -1,
|
ppid: -1,
|
||||||
cmd: "",
|
cmd: "",
|
||||||
expected: "UID=999 PID=123 | ",
|
expected: "UID=999 PID=123 | ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "nocmd-with-ppid",
|
name: "nocmd-with-ppid",
|
||||||
@@ -447,7 +447,7 @@ func TestPSEvent(t *testing.T) {
|
|||||||
pid: 123,
|
pid: 123,
|
||||||
ppid: 321,
|
ppid: 321,
|
||||||
cmd: "",
|
cmd: "",
|
||||||
expected: "UID=999 PID=123 PPID=321 | ",
|
expected: "UID=999 PID=123 PPID=321 | ",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "nouid",
|
name: "nouid",
|
||||||
@@ -455,7 +455,7 @@ func TestPSEvent(t *testing.T) {
|
|||||||
pid: 123,
|
pid: 123,
|
||||||
ppid: 321,
|
ppid: 321,
|
||||||
cmd: "some cmd",
|
cmd: "some cmd",
|
||||||
expected: "UID=??? PID=123 PPID=321 | some cmd",
|
expected: "UID=??? PID=123 PPID=321 | some cmd",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user