[klibc] Re: klibc - setenv broken

Kay Sievers kay.sievers at vrfy.org
Mon Feb 9 22:28:14 PST 2004


On Sun, Feb 08, 2004 at 09:44:13PM -0800, H. Peter Anvin wrote:
> Kay Sievers wrote:
> >Hi,
> >this simple program compiled with klibc:
> >
> >  #include <stdio.h>
> >  int main(int argc, char* argv[])
> >  {
> >        setenv("TESTENV", "happy", 1);
> >        printf("TESTENV='%s'\n", getenv("TESTENV"));
> >  }
> >
> >prints:
> >
> >  ./env
> >  TESTENV='(null)'
> >
> >
> >thanks,
> >Kay
> 
> Released klibc-0.104 to fix this bug, and in general clean up the 
> setenv/putenv implementation and testing.

You are very fast :)
It's fine now, thanks.

I needed a few changes to compile the last part of udev with klibc,
you may include it if you like it.

thanks,
Kay
-------------- next part --------------
diff -urN ../../klibc-0.105/klibc/Makefile ./klibc/Makefile
--- ../../klibc-0.105/klibc/Makefile	2004-02-09 06:41:29.000000000 +0100
+++ ./klibc/Makefile	2004-02-09 21:59:53.000000000 +0100
@@ -23,7 +23,7 @@
 	  fwrite.o fwrite2.o fputc.o fputs.o puts.o \
 	  sleep.o usleep.o raise.o abort.o assert.o alarm.o pause.o \
 	  __signal.o signal.o bsd_signal.o siglist.o siglongjmp.o \
-	  sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
+	  sigaction.o siginterrupt.o sigpending.o sigprocmask.o sigsuspend.o \
 	  brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o getpagesize.o \
 	  memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
 	  memmove.o \
diff -urN ../../klibc-0.105/klibc/include/signal.h ./klibc/include/signal.h
--- ../../klibc-0.105/klibc/include/signal.h	2003-12-13 04:43:21.000000000 +0100
+++ ./klibc/include/signal.h	2004-02-09 22:00:48.000000000 +0100
@@ -67,6 +67,7 @@
 __extern __sighandler_t signal(int, __sighandler_t);
 __extern __sighandler_t bsd_signal(int, __sighandler_t);
 __extern int sigaction(int, const struct sigaction *, struct sigaction *);
+__extern int siginterrupt(int, int);
 __extern int sigprocmask(int, const sigset_t *, sigset_t *);
 __extern int sigpending(sigset_t *);
 __extern int sigsuspend(const sigset_t *);
diff -urN ../../klibc-0.105/klibc/include/sys/un.h ./klibc/include/sys/un.h
--- ../../klibc-0.105/klibc/include/sys/un.h	1970-01-01 01:00:00.000000000 +0100
+++ ./klibc/include/sys/un.h	2004-02-09 03:37:41.000000000 +0100
@@ -0,0 +1,10 @@
+/*
+ * sys/un.h
+ */
+
+#ifndef _UN_H
+#define _UN_H
+
+#include <linux/un.h>
+
+#endif /* _UN_H */
diff -urN ../../klibc-0.105/klibc/siginterrupt.c ./klibc/siginterrupt.c
--- ../../klibc-0.105/klibc/siginterrupt.c	1970-01-01 01:00:00.000000000 +0100
+++ ./klibc/siginterrupt.c	2004-02-09 04:19:20.000000000 +0100
@@ -0,0 +1,21 @@
+/*
+ * siginterrupt.c
+ */
+
+#include <signal.h>
+
+int siginterrupt(int sig, int flag) {
+  int ret;
+  struct sigaction act;
+
+  sigaction(sig, 0, &act);
+
+  if (flag)
+    act.sa_flags &= ~SA_RESTART;
+  else
+    act.sa_flags |= SA_RESTART;
+
+  ret = sigaction(sig, &act, 0);
+
+  return ret;
+}
diff -urN ../../klibc-0.105/klibc/signal.c ./klibc/signal.c
--- ../../klibc-0.105/klibc/signal.c	2003-01-07 06:20:28.000000000 +0100
+++ ./klibc/signal.c	2004-02-09 22:10:03.000000000 +0100
@@ -7,5 +7,5 @@
 __sighandler_t signal(int signum, __sighandler_t handler)
 {
   /* Linux/SysV signal() semantics */
-  return __signal(signum, handler, SA_RESETHAND);
+  return __signal(signum, handler, SA_RESTART);
 }


More information about the klibc mailing list