Message ID | 20200725122442.1679820-2-vicamo.yang@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi You-Shang, Thank you for the patch. On Sat, Jul 25, 2020 at 08:24:40PM +0800, You-Sheng Yang wrote: > When a libcamera::process is being destructed or called kill() without a > previous successful call to start(), it's pid_ may remains -1, which > causes all the killable processes being killed when passed to > `kill(pid_, SIG_KILL)`. Oops. This is embarassing :-) > Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/process.cpp | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp > index e816ee8..8311d27 100644 > --- a/src/libcamera/process.cpp > +++ b/src/libcamera/process.cpp > @@ -373,7 +373,8 @@ void Process::died(int wstatus) > */ > void Process::kill() > { > - ::kill(pid_, SIGKILL); > + if (pid_ > 0) > + ::kill(pid_, SIGKILL); > } > > } /* namespace libcamera */
Hi You-Sheng, On 26/07/2020 23:42, Laurent Pinchart wrote: > Hi You-Shang, > > Thank you for the patch. > > On Sat, Jul 25, 2020 at 08:24:40PM +0800, You-Sheng Yang wrote: >> When a libcamera::process is being destructed or called kill() without a >> previous successful call to start(), it's pid_ may remains -1, which >> causes all the killable processes being killed when passed to >> `kill(pid_, SIG_KILL)`. > > Oops. This is embarassing :-) Ouch ouch ouch! >> Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > >> --- >> src/libcamera/process.cpp | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp >> index e816ee8..8311d27 100644 >> --- a/src/libcamera/process.cpp >> +++ b/src/libcamera/process.cpp >> @@ -373,7 +373,8 @@ void Process::died(int wstatus) >> */ >> void Process::kill() >> { >> - ::kill(pid_, SIGKILL); >> + if (pid_ > 0) >> + ::kill(pid_, SIGKILL); >> } >> >> } /* namespace libcamera */ >
diff --git a/src/libcamera/process.cpp b/src/libcamera/process.cpp index e816ee8..8311d27 100644 --- a/src/libcamera/process.cpp +++ b/src/libcamera/process.cpp @@ -373,7 +373,8 @@ void Process::died(int wstatus) */ void Process::kill() { - ::kill(pid_, SIGKILL); + if (pid_ > 0) + ::kill(pid_, SIGKILL); } } /* namespace libcamera */
When a libcamera::process is being destructed or called kill() without a previous successful call to start(), it's pid_ may remains -1, which causes all the killable processes being killed when passed to `kill(pid_, SIG_KILL)`. Signed-off-by: You-Sheng Yang <vicamo.yang@canonical.com> --- src/libcamera/process.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)