summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-05-05 12:50:24 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-05-05 12:50:24 +0000
commit7d06701bfaad445e48832ba4fd189ffc36e34387 (patch)
treec3d0d5da0d9328d950a4da4cc3a4f9d84a3e7033 /src/libstddjb
parent73ebb5709dc2a5aaee1e676a3c1b0bb7cebcd392 (diff)
downloadskalibs-7d06701bfaad445e48832ba4fd189ffc36e34387.tar.xz
- add stat_at
- make case_diff* work as a function is more cases - make sig_number case-insensitive - make child signal unblocking work in child_spawn*
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/case_diffb.c15
-rw-r--r--src/libstddjb/case_diffs.c6
-rw-r--r--src/libstddjb/child_spawn.c3
-rw-r--r--src/libstddjb/child_spawn0.c5
-rw-r--r--src/libstddjb/child_spawn1_internal.c3
-rw-r--r--src/libstddjb/sig_number.c2
6 files changed, 27 insertions, 7 deletions
diff --git a/src/libstddjb/case_diffb.c b/src/libstddjb/case_diffb.c
index 1931c0f..f267756 100644
--- a/src/libstddjb/case_diffb.c
+++ b/src/libstddjb/case_diffb.c
@@ -1,7 +1,11 @@
/* ISC license. */
+#include <skalibs/config.h>
#include <skalibs/bytestr.h>
+#ifdef SKALIBS_FLAG_REPLACE_LIBC
+
+
int case_diffb (char const *s, unsigned int len, char const *t)
{
register unsigned char x = 0, y = 0 ;
@@ -16,3 +20,14 @@ int case_diffb (char const *s, unsigned int len, char const *t)
}
return (int)(x - y) ;
}
+
+else
+
+#include <strings.h>
+
+int case_diffb (char const *s, unsigned int len, char const *t)
+{
+ return strncasecmp(s, t, len) ;
+}
+
+#endif
diff --git a/src/libstddjb/case_diffs.c b/src/libstddjb/case_diffs.c
index 2731408..bf72472 100644
--- a/src/libstddjb/case_diffs.c
+++ b/src/libstddjb/case_diffs.c
@@ -1,7 +1,11 @@
/* ISC license. */
+#include <skalibs/config.h>
#include <skalibs/bytestr.h>
+#ifdef SKALIBS_FLAG_REPLACE_LIBC
+
+
int case_diffs (char const *s, char const *t)
{
register unsigned char x = 1, y = 1 ;
@@ -16,3 +20,5 @@ int case_diffs (char const *s, char const *t)
}
return (int)(x - y) ;
}
+
+#endif
diff --git a/src/libstddjb/child_spawn.c b/src/libstddjb/child_spawn.c
index 922c777..18cee96 100644
--- a/src/libstddjb/child_spawn.c
+++ b/src/libstddjb/child_spawn.c
@@ -75,8 +75,7 @@ pid_t child_spawn (char const *prog, char const *const *argv, char const *const
sigemptyset(&set) ;
e = posix_spawnattr_setsigmask(&attr, &set) ;
if (e) goto errattr ;
- sigfillset(&set) ;
- e = posix_spawnattr_setsigdefault(&attr, &set) ;
+ e = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK) ;
if (e) goto errattr ;
}
e = posix_spawn_file_actions_init(&actions) ;
diff --git a/src/libstddjb/child_spawn0.c b/src/libstddjb/child_spawn0.c
index 7129515..bb8b29e 100644
--- a/src/libstddjb/child_spawn0.c
+++ b/src/libstddjb/child_spawn0.c
@@ -25,8 +25,7 @@ pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const
sigemptyset(&set) ;
e = posix_spawnattr_setsigmask(&attr, &set) ;
if (e) goto errattr ;
- sigfillset(&set) ;
- e = posix_spawnattr_setsigdefault(&attr, &set) ;
+ e = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK) ;
if (e) goto errattr ;
}
if (!haspath && (setenv("PATH", SKALIBS_DEFAULTPATH, 0) < 0)) { e = errno ; goto errattr ; }
@@ -47,6 +46,7 @@ pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const
#include <unistd.h>
#include <skalibs/allreadwrite.h>
+#include <skalibs/sig.h>
#include <skalibs/djbunix.h>
pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const *envp)
@@ -67,6 +67,7 @@ pid_t child_spawn0 (char const *prog, char const *const *argv, char const *const
if (pid)
{
fd_close(p[0]) ;
+ sig_blocknone() ;
pathexec_run(prog, argv, envp) ;
e = errno ;
fd_write(p[1], (char *)&e, sizeof(e)) ;
diff --git a/src/libstddjb/child_spawn1_internal.c b/src/libstddjb/child_spawn1_internal.c
index 8347f69..f833a15 100644
--- a/src/libstddjb/child_spawn1_internal.c
+++ b/src/libstddjb/child_spawn1_internal.c
@@ -29,8 +29,7 @@ pid_t child_spawn1_internal (char const *prog, char const *const *argv, char con
sigemptyset(&set) ;
e = posix_spawnattr_setsigmask(&attr, &set) ;
if (e) goto errattr ;
- sigfillset(&set) ;
- e = posix_spawnattr_setsigdefault(&attr, &set) ;
+ e = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGMASK) ;
if (e) goto errattr ;
}
e = posix_spawn_file_actions_init(&actions) ;
diff --git a/src/libstddjb/sig_number.c b/src/libstddjb/sig_number.c
index 93d9b59..cbd897d 100644
--- a/src/libstddjb/sig_number.c
+++ b/src/libstddjb/sig_number.c
@@ -7,6 +7,6 @@
int sig_number (char const *name)
{
register sigtable_t const *p = skalibs_sigtable ;
- for (; p->name ; p++) if (!str_diff(name, p->name)) break ;
+ for (; p->name ; p++) if (!case_diffs(name, p->name)) break ;
return p->number ;
}