virtiofsd: Check if PID is valid

If try to kill with an not valid PID the thread goes to panic, check
to allow return a valid error from the runtime.

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
Jose Carlos Venegas Munoz 2020-03-07 00:02:26 +00:00
parent 3251beaa23
commit 6a4e667f9c

View File

@ -217,6 +217,10 @@ func (v *virtiofsd) kill() (err error) {
span, _ := v.trace("kill")
defer span.Finish()
if v.PID == 0 {
return errors.New("invalid virtiofsd PID(0)")
}
err = syscall.Kill(v.PID, syscall.SIGKILL)
if err != nil {
v.PID = 0