mirror of
https://github.com/safing/portmaster
synced 2025-09-04 11:39:29 +00:00
Save failed processes
This commit is contained in:
parent
53eb309e72
commit
652518e527
1 changed files with 15 additions and 8 deletions
|
@ -49,7 +49,8 @@ type Process struct {
|
||||||
FirstSeen int64
|
FirstSeen int64
|
||||||
LastSeen int64
|
LastSeen int64
|
||||||
|
|
||||||
Virtual bool // This process is either merged into another process or is not needed.
|
Virtual bool // This process is either merged into another process or is not needed.
|
||||||
|
Error string // Cache errors
|
||||||
}
|
}
|
||||||
|
|
||||||
// Profile returns the assigned layered profile.
|
// Profile returns the assigned layered profile.
|
||||||
|
@ -94,6 +95,7 @@ func GetOrFindPrimaryProcess(ctx context.Context, pid int) (*Process, error) {
|
||||||
parentProcess, err := loadProcess(ctx, process.ParentPid)
|
parentProcess, err := loadProcess(ctx, process.ParentPid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Tracer(ctx).Tracef("process: could not get parent of %d: %d: %s", process.Pid, process.ParentPid, err)
|
log.Tracer(ctx).Tracef("process: could not get parent of %d: %d: %s", process.Pid, process.ParentPid, err)
|
||||||
|
saveFailedProcess(process.ParentPid, err.Error())
|
||||||
return process, nil
|
return process, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,13 +228,7 @@ func loadProcess(ctx context.Context, pid int) (*Process, error) {
|
||||||
|
|
||||||
pInfo, err := processInfo.NewProcess(int32(pid))
|
pInfo, err := processInfo.NewProcess(int32(pid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: remove this workaround as soon as NewProcess really returns an error on windows when the process does not exist
|
return nil, err
|
||||||
// Issue: https://github.com/shirou/gopsutil/issues/729
|
|
||||||
_, err = pInfo.Name()
|
|
||||||
if err != nil {
|
|
||||||
// process does not exists
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UID
|
// UID
|
||||||
|
@ -375,3 +371,14 @@ func loadProcess(ctx context.Context, pid int) (*Process, error) {
|
||||||
new.Save()
|
new.Save()
|
||||||
return new, nil
|
return new, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func saveFailedProcess(pid int, err string) {
|
||||||
|
failed := &Process{
|
||||||
|
Pid: pid,
|
||||||
|
FirstSeen: time.Now().Unix(),
|
||||||
|
Virtual: true, // not needed
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
|
||||||
|
failed.Save()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue