summaryrefslogtreecommitdiffstats
path: root/main/vlc/uclibc-inhibit-spawn.patch
blob: 75cff1bb6b397d5c2643733f283b3973c1909541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
diff --git a/modules/misc/inhibit/xdg.c b/modules/misc/inhibit/xdg.c
index cfb3b2a..16a2ce9 100644
--- a/modules/misc/inhibit/xdg.c
+++ b/modules/misc/inhibit/xdg.c
@@ -26,7 +26,11 @@
 #include <vlc_plugin.h>
 #include <vlc_inhibit.h>
 #include <assert.h>
-#include <spawn.h>
+#if !defined(_POSIX_SPAWN)
+# define _POSIX_SPAWN -1
+#else
+# include <spawn.h>
+#endif
 #include <sys/wait.h>
 
 static int Open (vlc_object_t *);
@@ -46,7 +50,9 @@ struct vlc_inhibit_sys
     vlc_thread_t thread;
     vlc_cond_t update, inactive;
     vlc_mutex_t lock;
+#if (_POSIX_SPAWN >= 0)
     posix_spawnattr_t attr;
+#endif
     bool suspend, suspended;
 };
 
@@ -66,17 +72,21 @@ static int Open (vlc_object_t *obj)
     vlc_mutex_init (&p_sys->lock);
     vlc_cond_init (&p_sys->update);
     vlc_cond_init (&p_sys->inactive);
+#if (_POSIX_SPAWN >= 0)
     posix_spawnattr_init (&p_sys->attr);
+#endif
     /* Reset signal handlers to default and clear mask in the child process */
     {
         sigset_t set;
 
         sigemptyset (&set);
-        posix_spawnattr_setsigmask (&p_sys->attr, &set);
         sigaddset (&set, SIGPIPE);
+#if (_POSIX_SPAWN >= 0)
+        posix_spawnattr_setsigmask (&p_sys->attr, &set);
         posix_spawnattr_setsigdefault (&p_sys->attr, &set);
         posix_spawnattr_setflags (&p_sys->attr, POSIX_SPAWN_SETSIGDEF
                                               | POSIX_SPAWN_SETSIGMASK);
+#endif
     }
     p_sys->suspend = false;
     p_sys->suspended = false;
@@ -105,7 +115,9 @@ static void Close (vlc_object_t *obj)
 
     vlc_cancel (p_sys->thread);
     vlc_join (p_sys->thread, NULL);
+#if (_POSIX_SPAWN >= 0)
     posix_spawnattr_destroy (&p_sys->attr);
+#endif
     vlc_cond_destroy (&p_sys->inactive);
     vlc_cond_destroy (&p_sys->update);
     vlc_mutex_destroy (&p_sys->lock);
@@ -152,8 +164,16 @@ static void *Thread (void *data)
         pid_t pid;
 
         vlc_mutex_unlock (&p_sys->lock);
+#if (_POSIX_SPAWN >= 0)
         if (!posix_spawnp (&pid, "xdg-screensaver", NULL, &p_sys->attr,
                            argv, environ))
+#else
+        pid = fork();
+        if (pid == 0) {
+            execvp("xdg-screensaver", argv);
+            exit(1);
+        } else if (pid > 0)
+#endif
         {
             int status;