Skip to content

Commit

Permalink
Fix: Updated comments for better understanding
Browse files Browse the repository at this point in the history
Signed-off-by: GLVS Kiriti <glvskiriti2003369@gmail.com>
  • Loading branch information
GLVSKiriti authored and poiana committed Apr 4, 2024
1 parent 2a3d1bf commit 2250ff8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions events/syscall/ptrace_attached_to_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
var _ = events.Register(PtraceAttachedToProcess)

func PtraceAttachedToProcess(h events.Helper) error {
// Start a dummy process
// Start a dummy process which sleeps for 1hr
cmd := exec.Command("sleep", "3600")
if err := cmd.Start(); err != nil {
h.Log().WithError(err).Error("Failed to start dummy process")
Expand All @@ -34,8 +34,8 @@ func PtraceAttachedToProcess(h events.Helper) error {

h.Log().Infof("Attached to dummy process with PID %d using PTRACE_ATTACH", pid)

defer syscall.PtraceDetach(pid)
defer cmd.Process.Kill()
defer syscall.PtraceDetach(pid) // Detach the process at end
defer cmd.Process.Kill() // Kill the dummy process at end

// Attach to the target process using PTRACE_ATTACH
return syscall.PtraceAttach(pid)
Expand Down

0 comments on commit 2250ff8

Please sign in to comment.