diff options
Diffstat (limited to 'internal/procs/chldspawn.go')
| -rw-r--r-- | internal/procs/chldspawn.go | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/internal/procs/chldspawn.go b/internal/procs/chldspawn.go index eb7db69..391581d 100644 --- a/internal/procs/chldspawn.go +++ b/internal/procs/chldspawn.go @@ -2,13 +2,40 @@ package procs import ( "context" - "os" + "fmt" + "os/exec" "github.com/Wacky404/lurchers/internal/url" ) +type Pid int + type Proc struct { - ID *os.Process - ctx context.Context + PID Pid + cmd *exec.Cmd opts *url.UserParams } + +func (p *Proc) NewChildProc(ctx context.Context, offset int) (Pid, error) { + // --offset is byte offset of ring buffer in mem file from mmap + // --options is packed json of user params for jac file to restrict job(s) to + // need to read docs on exec lib and spawning child procs in go + // howler --offset val1 --options val2 + (*p).cmd = exec.Command("howler", fmt.Sprintf("--offset %d --options %v", offset, (*p).opts)) + err := (*p).cmd.Start() + if err != nil { + return nil, err + } + (*p).PID = Pid((*p).cmd.Process.Pid) + return (*p).PID, nil +} + +func NewProc(prog string, flags []string) *Proc { + if !prog { + prog = "howler" + } + return &Proc{ + PID: nil, + cmd: exec.Command() + } +} |
