Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
Check if there's running processes in the job object before promoting to
a silo

Signed-off-by: Daniel Canter <dcanter@microsoft.com>
  • Loading branch information
dcantah committed Mar 24, 2022
1 parent 1bbaa26 commit b365995
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions internal/jobobject/jobobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
// of the job and a mutex for synchronized handle access.
type JobObject struct {
handle windows.Handle
// All accesses to this MUST be done atomically. 1 signifies that this job
// is currently a silo.
// All accesses to this MUST be done atomically. 1 signifies that this
// job is currently a silo.
isAppSilo uint32
mq *queue.MessageQueue
handleLock sync.RWMutex
Expand Down Expand Up @@ -522,7 +522,16 @@ func (job *JobObject) PromoteToSilo() error {
return nil
}

_, err := windows.SetInformationJobObject(
pids, err := job.Pids()
if err != nil {
return err
}

if len(pids) != 0 {
return fmt.Errorf("job cannot have running processes to be promoted to a silo, found %d running processes", len(pids))
}

_, err = windows.SetInformationJobObject(
job.handle,
winapi.JobObjectCreateSilo,
0,
Expand Down

0 comments on commit b365995

Please sign in to comment.