This is the mail archive of the
libc-ports@sources.redhat.com
mailing list for the libc-ports project.
[Patch][RFC] ARM glibc-2.5 sigwait() with linuxthreads has a problem.
- From: ryosei at sm dot sony dot co dot jp
- To: libc-ports at sourceware dot org
- Cc: ryosei at sm dot sony dot co dot jp, Satoru dot Ueda at jp dot sony dot com
- Date: Tue, 13 Nov 2007 18:58:09 +0900 (JST)
- Subject: [Patch][RFC] ARM glibc-2.5 sigwait() with linuxthreads has a problem.
Hi all,
I am using the following ARM toolchain and found a problem with
respect to sigwait().
binutils: binutils-2.17
gcc: gcc-4.1.1
glibc: glibc-2.5/glibc-linuxthreads-2.5
The problem is that sigwait() doesn't store the number of the
signal received in some cases.
Sample codes, build procedures and an execution result are as follows.
[sample codes]
--- main.c ---
extern int func(void);
int
main(void)
{
func();
return 0;
}
--- func.c ---
#include <stdio.h>
#include <pthread.h>
#include <signal.h>
sigset_t signal_set;
void *
thread_routine(void *arg)
{
int signum;
sigwait(&signal_set, &signum);
if(signum == SIGUSR1)
printf("OK: SIGUSR1\n");
else
printf("NG: %d\n", signum);
return 0;
}
int
func(void)
{
pthread_t th;
int ret;
sigemptyset(&signal_set);
sigaddset(&signal_set, SIGUSR1);
pthread_sigmask(SIG_BLOCK, &signal_set, NULL);
pthread_create(&th, NULL, thread_routine, NULL);
/* wait for a while and send a signal*/
sleep(1);
pthread_kill(th, SIGUSR1);
pthread_join(th, NULL);
return 0;
}
[build procedures]
$ arm-unknown-linux-gnueabi-gcc -shared -o func.so func.c -fPIC -lpthread
$ arm-unknown-linux-gnueabi-gcc -o main main.c func.so
[execution result]
# LD_LIBRARY_PATH=./ ./main
NG: 0
As the execution result, sigwait() doesn't store the signal
number[SIGUSR1]!
I suppose the cause of this problem is as follows.
* In the case of above sample codes, pthread_sigwait() in libpthread.so
call sigaction() in libc.so
* And sigaction() in libc.so doesn't call pthread_sigaction()
in libpthread.so.
* This is because the following file exists but is not compiled.
linuxthreads/sysdeps/pthread/sigaction.c
Are there any reasons why the above file,
sigaction.c in linuxthreads directory, is not compiled??
# I have confirmed that in the case of glibc-2.3.6/glibc-linuxthreads-2.3.6
# the above sigaction.c is compiled.
With the below patch which I created, the above sigaction.c is compiled
and the problem is fixed. Is this patch fine??
Best Regards,
Ryosei Takagi
diff -Naur glibc-ports-2.5.orig/sysdeps/unix/sysv/linux/arm/linuxthreads/sigaction.c glibc-ports-2.5/sysdeps/unix/sysv/linux/arm/linuxthreads/sigaction.c
--- glibc-ports-2.5.orig/sysdeps/unix/sysv/linux/arm/linuxthreads/sigaction.c 1970-01-01 00:00:00.000000000 +0000
+++ glibc-ports-2.5/sysdeps/unix/sysv/linux/arm/linuxthreads/sigaction.c 2007-11-13 03:59:06.000000000 +0000
@@ -0,0 +1,5 @@
+#ifndef LIBC_SIGACTION
+# include <linuxthreads/sysdeps/pthread/sigaction.c>
+#else
+# include_next <sigaction.c>
+#endif