This is a uLibc fault. A common idiom, from way back, is: close(creat(...));
Close is supposed to be able to survive being given a negative number. -- Jim -----Original Message----- From: busybox-boun...@busybox.net [mailto:busybox-boun...@busybox.net] On Behalf Of Waldemar Brodkorb Sent: Monday, September 24, 2012 12:12 PM To: busybox@busybox.net Subject: utmp fix for mips64 uClibc systems Hi Developers, I have some strange problem with getty, init and login on mips64 uClibc (0.9.33.2) systems: qemu-system-mips64, big endian, n64 lemote yeelong, little endian, n32 Following test code segfaults: #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main() { int n; n=open("/dev/nul", O_RDWR); close(n); return(0); } When close get a -1 as argument, it segfaults. Suggested patch for libbb/utmp.c to avoid this in the mentioned apps: best regards Waldemar --- >From f1b662fe3a847c190c46f93c0f13002ee3ca6c0c Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb <w...@openadk.org> Date: Mon, 24 Sep 2012 21:10:52 +0200 Subject: [PATCH] close(-1) segfaults on mips64 uClibc systems Signed-off-by: Waldemar Brodkorb <w...@openadk.org> --- libbb/utmp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libbb/utmp.c b/libbb/utmp.c index 09443fb..c56fdb3 100644 --- a/libbb/utmp.c +++ b/libbb/utmp.c @@ -10,8 +10,14 @@ static void touch(const char *filename) { - if (access(filename, R_OK | W_OK) == -1) - close(open(filename, O_WRONLY | O_CREAT, 0664)); + int c = 0; + + if (access(filename, R_OK | W_OK) == -1) { + c=open(filename, O_WRONLY | O_CREAT, 0664); + if (c > 0) { + close(c); + } + } } void FAST_FUNC write_new_utmp(pid_t pid, int new_type, const char *tty_name, const char *username, const char *hostname) -- 1.7.10.4 _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox _______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox