-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecFirefox.go
More file actions
33 lines (27 loc) · 934 Bytes
/
ExecFirefox.go
File metadata and controls
33 lines (27 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package boxes
import "os/exec"
type ProcessID int
type ExecPIDs map[ProfileID]ProcessID
var Exec ExecPIDs = make(ExecPIDs)
func (execPIDs *ExecPIDs) IsRunning(profileID ProfileID) (bool, ProcessID) {
val, ok := (*execPIDs)[profileID]
return ok, val
}
func (I *Installation) ExecProfile(profileID ProfileID, pr ProbeResult) {
cmd := exec.Command(I.Exec, "-profile", pr.GetProfileDir(profileID), "-no-remote")
cmd.Start()
Exec[profileID] = ProcessID(cmd.Process.Pid)
cmd.Wait()
delete(Exec, profileID)
}
func waitAndDeleteProcessIDLater(cmd *exec.Cmd, profileID ProfileID) {
cmd.Wait()
delete(Exec, profileID)
}
func (I *Installation) ExecProfileAndDetach(profileID ProfileID, pr ProbeResult) ProcessID {
cmd := exec.Command(I.Exec, "-profile", pr.GetProfileDir(profileID), "-no-remote")
cmd.Start()
Exec[profileID] = ProcessID(cmd.Process.Pid)
go waitAndDeleteProcessIDLater(cmd, profileID)
return Exec[profileID]
}