+static char *FromSystem(const void *str)
+{
+ iconv_t handle = iconv_open ("UTF-8", "");
+ if (handle == (iconv_t)(-1))
+ return NULL;
+
+ size_t str_len = strlen (str);
+ char *out = NULL;
+ for (unsigned mul = 4; mul < 8; mul++)
+ {
+ size_t in_size = str_len;
+ const char *in = str;
+ size_t out_max = mul * str_len;
+ char *tmp = out = malloc (1 + out_max);
+ if (!out)
+ break;
+
+ if (iconv (handle, &in, &in_size, &tmp, &out_max) != (size_t)(-1)) {
+ *tmp = '\0';
+ break;
+ }
+ free(out);
+ out = NULL;
+
+ if (errno != E2BIG)
+ break;
+ }
+ iconv_close(handle);
+ return out;
+}
+#endif
+
+extern void vlc_enable_override (void);
+
+static bool signal_ignored (int signum)
+{
+ struct sigaction sa;
+
+ if (sigaction (signum, NULL, &sa))
+ return false;
+ return ((sa.sa_flags & SA_SIGINFO)
+ ? (void *)sa.sa_sigaction : (void *)sa.sa_handler) == SIG_IGN;
+}
+
+static void vlc_kill (void *data)
+{
+#ifndef __OS2__
+ pthread_t *ps = data;
+
+ pthread_kill (*ps, SIGTERM);
+#else
+ // send a signal to the main thread
+ kill (getpid(), SIGTERM);
+#endif
+}
+
+static void exit_timeout (int signum)
+{
+ (void) signum;
+ signal (SIGINT, SIG_DFL);
+}