Implement container signaling

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2015-02-06 22:33:10 -08:00
parent 0c1919c427
commit 9dcbc4f3f8
3 changed files with 15 additions and 1 deletions

View File

@ -230,7 +230,7 @@ func (c *linuxContainer) Resume() error {
func (c *linuxContainer) Signal(signal os.Signal) error {
glog.Infof("sending signal %d to pid %d", signal, c.initProcess.pid())
panic("not implemented")
return c.initProcess.signal(signal)
}
// TODO: rename to be more descriptive

View File

@ -224,3 +224,7 @@ func (p *restoredProcess) wait() (*os.ProcessState, error) {
func (p *restoredProcess) startTime() (string, error) {
return p.processStartTime, nil
}
func (p *restoredProcess) signal(s os.Signal) error {
return newGenericError(fmt.Errorf("restored process cannot be signaled"), SystemError)
}

View File

@ -32,6 +32,8 @@ type parentProcess interface {
// startTime return's the process start time.
startTime() (string, error)
signal(os.Signal) error
}
type setnsProcess struct {
@ -47,6 +49,10 @@ func (p *setnsProcess) startTime() (string, error) {
return system.GetProcessStartTime(p.pid())
}
func (p *setnsProcess) signal(s os.Signal) error {
return p.forkedProcess.Signal(s)
}
func (p *setnsProcess) start() (err error) {
defer p.parentPipe.Close()
if p.forkedProcess, err = p.execSetns(); err != nil {
@ -260,3 +266,7 @@ func (p *initProcess) newUsernsSetupProcess() (parentProcess, error) {
config: p.config,
}, nil
}
func (p *initProcess) signal(s os.Signal) error {
return p.cmd.Process.Signal(s)
}