Hi, Your code runs without any problem on SL9.3. SL9.2 should also be ok, but I have no environment to test. Maybe you should consider to upgrade to SL9.3 :-) Regards James Su Klaus Schneider wrote:
Hello!
I'm trying to write an app using POSIX timers. But timer_create() fails everytime I call it with "Resource temporarily unavailable". This must be a SuSE problem: The program works on QNX and on my Debian Linux machine at home. What could be causing this problem? Perhaps it's something in the SuSE kernel or with SuSE's glibc? I have searched through google and mailing lists but there was nothing, and I have no idea what to do. Many Thanks!
Klaus
My System: Distribution: SuSE 9.2 Linux werckmeister 2.6.8-24.13-default #1 Fri Mar 18 10:19:42 UTC 2005 i686 i686 i386 GNU/Linux GNU C Library stable release version 2.3.3 (20040917), by Roland McGrath et al. Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Configured for i686-suse-linux. Compiled by GNU CC version 3.3.4 (pre 3.3.5 20040809). Compiled on a Linux 2.6.8.1 system on 2004-10-05. Available extensions: GNU libio by Per Bothner crypt add-on version 2.1 by Michael Glad and others linuxthreads-0.10 by Xavier Leroy GNU Libidn by Simon Josefsson NoVersion patch for broken glibc 2.0 binaries BIND-8.2.3-T5B libthread_db work sponsored by Alpha Processor Inc NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk Thread-local storage support included.
My code: #include
#include #include /* perror() */ /* prototype */ void timer_handler(int);
int main(void) { struct sigevent sig_spec; sigset_t allsigs; struct itimerspec tmr_setting; timer_t timer_id; /* setup signal to respond to timer */ if (signal(SIGALRM, timer_handler) == SIG_ERR) { perror("signal"); return -1; } /* create timer, which uses the REALTIME clock */ sig_spec.sigev_signo = SIGALRM; #ifdef __QNX__ /* QNX has slightly other prototype */ if ((timer_id = timer_create(CLOCK_REALTIME, &sig_spec)) < 0) { #else sig_spec.sigev_notify = SIGEV_SIGNAL; if (timer_create(CLOCK_REALTIME, &sig_spec, &timer_id) < 0) { #endif perror("timer_create"); return -1; } /* set the initial expiration and frequency of timer */ tmr_setting.it_value.tv_sec = 1; tmr_setting.it_value.tv_nsec = 0; tmr_setting.it_interval.tv_sec = 1; tmr_setting.it_interval.tv_nsec = 0; if (timer_settime(timer_id, 0, &tmr_setting, NULL) < 0) { perror("settimer"); return -1; } /* wait for signals */ sigemptyset(&allsigs); while (1) { sigsuspend(&allsigs); printf("signal\n"); } }
/* signal routine */ void timer_handler(int signum) { printf("timer\n"); }