it just works

This commit is contained in:
2023-01-12 23:18:50 +01:00
parent f8091b6d14
commit 5e3a40baf4
4 changed files with 18 additions and 6 deletions

View File

@@ -167,6 +167,7 @@ func (p *Process) Complete() {
// Kill a process and remove it from the memory
func (p *Process) Kill() error {
p.mem.Delete(p.id)
// yt-dlp uses multiple child process the parent process
// has been spawned with setPgid = true. To properly kill
// all subprocesses a SIGTERM need to be sent to the correct
@@ -176,8 +177,8 @@ func (p *Process) Kill() error {
return err
}
err = syscall.Kill(-pgid, syscall.SIGTERM)
p.mem.Delete(p.id)
log.Printf("Killed process %s\n", p.id)
log.Println("Killed process", p.id)
return err
}

View File

@@ -90,6 +90,13 @@ func (t *Service) KillAll(args NoArgs, killed *string) error {
return err
}
// Remove a process from the db rendering it unusable if active
func (t *Service) Clear(args string, killed *string) error {
log.Println("Clearing process with id", args)
db.Delete(args)
return nil
}
// FreeSpace gets the available from package sys util
func (t *Service) FreeSpace(args NoArgs, free *uint64) error {
freeSpace, err := sys.FreeSpace()