diff mbox

backlight: Do not hang forever if helper pid is -1

Message ID 1430299187-21049-1-git-send-email-ofourdan@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Olivier Fourdan April 29, 2015, 9:19 a.m. UTC
Backlight helper PID is set to -1 by default, if for some reason it's
not set, we may end up with waitpid(-1, ...) which will hang forever.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90230
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
---
 src/backlight.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chris Wilson April 29, 2015, 9:35 a.m. UTC | #1
On Wed, Apr 29, 2015 at 11:19:47AM +0200, Olivier Fourdan wrote:
> Backlight helper PID is set to -1 by default, if for some reason it's
> not set, we may end up with waitpid(-1, ...) which will hang forever.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90230
> Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>

Nice catch. Pushed with thanks,
   1a67dac..e7016d3  master -> master
-Chris
diff mbox

Patch

diff --git a/src/backlight.c b/src/backlight.c
index 84d8f76..c65e466 100644
--- a/src/backlight.c
+++ b/src/backlight.c
@@ -523,7 +523,7 @@  void backlight_disable(struct backlight *b)
 void backlight_close(struct backlight *b)
 {
 	backlight_disable(b);
-	if (b->pid)
+	if (b->pid > 0)
 		waitpid(b->pid, NULL, 0);
 }