Add adds a process to global list and returns its PID.
(desc string, cmd *exec.Cmd)
| 42 | |
| 43 | // Add adds a process to global list and returns its PID. |
| 44 | func Add(desc string, cmd *exec.Cmd) int64 { |
| 45 | counter.Lock() |
| 46 | defer counter.Unlock() |
| 47 | |
| 48 | pid := counter.PID() |
| 49 | Processes = append(Processes, &Process{ |
| 50 | PID: pid, |
| 51 | Description: desc, |
| 52 | Start: time.Now(), |
| 53 | Cmd: cmd, |
| 54 | }) |
| 55 | return pid |
| 56 | } |
| 57 | |
| 58 | // Remove removes a process from global list. |
| 59 | // It returns true if the process is found and removed by given pid. |
no test coverage detected