[totem/gnome-2-28] Fix spurious errors when running nice()



commit ac5c99c562c57ad7f0c0ccf89f1a8e3af61f39fc
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Nov 16 13:21:00 2009 +0000

    Fix spurious errors when running nice()
    
    Check the value of errno before saying that nice() fails, as
    per the nice(3p) man page.

 src/totem-video-thumbnailer.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/totem-video-thumbnailer.c b/src/totem-video-thumbnailer.c
index b0cd569..0545291 100644
--- a/src/totem-video-thumbnailer.c
+++ b/src/totem-video-thumbnailer.c
@@ -32,6 +32,7 @@
 #include <glib/gi18n.h>
 #include <cairo.h>
 
+#include <errno.h>
 #include <unistd.h>
 #include <string.h>
 #include <math.h>
@@ -774,11 +775,6 @@ int main (int argc, char *argv[])
 	const char *input, *output;
 	callback_data data;
 
-#ifdef G_OS_UNIX
-	if (nice (20) != 20)
-		g_warning ("Couldn't change nice value of process.");
-#endif
-
 	g_thread_init (NULL);
 
 	context = g_option_context_new ("Thumbnail movies");
@@ -797,6 +793,14 @@ int main (int argc, char *argv[])
 		return 1;
 	}
 
+#ifdef G_OS_UNIX
+	if (time_limit != FALSE) {
+		errno = 0;
+		if (nice (20) != 20 && errno != 0)
+			g_warning ("Couldn't change nice value of process.");
+	}
+#endif
+
 	if (print_progress) {
 		fcntl (fileno (stdout), F_SETFL, O_NONBLOCK);
 		setbuf (stdout, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]