aboutsummaryrefslogtreecommitdiffstats
path: root/ports/unix/pseudo_wrappers.c
diff options
context:
space:
mode:
Diffstat (limited to 'ports/unix/pseudo_wrappers.c')
-rw-r--r--ports/unix/pseudo_wrappers.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/ports/unix/pseudo_wrappers.c b/ports/unix/pseudo_wrappers.c
new file mode 100644
index 0000000..dddb1ec
--- /dev/null
+++ b/ports/unix/pseudo_wrappers.c
@@ -0,0 +1,50 @@
+FILE *
+popen(const char *command, const char *mode) {
+ sigset_t saved;
+
+ FILE *rc = NULL;
+
+ if (!pseudo_check_wrappers() || !real_popen) {
+ /* rc was initialized to the "failure" value */
+ pseudo_enosys("popen");
+ return rc;
+ }
+
+ pseudo_debug(4, "called: popen\n");
+ pseudo_sigblock(&saved);
+ if (pseudo_getlock()) {
+ errno = EBUSY;
+ sigprocmask(SIG_SETMASK, &saved, NULL);
+ return NULL;
+ }
+
+ int save_errno;
+ /* exec*() use this to restore the sig mask */
+ pseudo_saved_sigmask = saved;
+ rc = wrap_popen(command, mode);
+
+ save_errno = errno;
+ pseudo_droplock();
+ sigprocmask(SIG_SETMASK, &saved, NULL);
+#if 0
+/* This can cause hangs on some recentish systems which use locale
+ * stuff for strerror...
+ */
+ pseudo_debug(4, "completed: popen (maybe: %s)\n", strerror(save_errno));
+#endif
+ pseudo_debug(4, "completed: popen (errno: %d)\n", save_errno);
+ errno = save_errno;
+ return rc;
+}
+
+static FILE *
+wrap_popen(const char *command, const char *mode) {
+ FILE *rc = NULL;
+
+
+
+#include "guts/popen.c"
+
+ return rc;
+}
+