timer_create on SCO ODT 5.0 not working!

timer_create on SCO ODT 5.0 not working!

Post by Paul McR » Thu, 21 Mar 1996 04:00:00



We have code that uses the POSIX timer functions, timer_create and
timer_settime.  We have enabled the suds library to allow us to
call these functions, but our program never gets the signal it is
expecting when the timer expires.  Under Solaris 2,4, the same code
works flawlessly.

One problem is the constant that is listed in the documentation,
SIGEV_SIGNAL, that is specified to indicate that you want to be
signalled when the timer expires is not defined in any of the SCO
header files.  We have used the value 2 and the value of SIGEV_NOTIFY
to try to get this to work, but it doesn't.

Has anyone gotten these timers to work?


PS.  

This is the program that will generate the error (it just hangs on SCO
ODT 5.0).

/* compile command under sco
 * cc -D_POSIXTIMERS timer_test.c -lsuds
 */    

#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <errno.h>

int hdl()
{
   printf("got a signal\n");
   fflush(stdout);

Quote:}

void main()
{
   int i, status;
   timer_t           tid;
   struct itimerspec tval;
   struct sigevent   evp;

   evp.sigev_notify = SIGEV_SIGNAL; /* try 2 or SIG_NOTIFY */
   evp.sigev_signo  = SIGUSR2;

   status = timer_create(CLOCK_REALTIME, &evp, &tid);
   if (status)
        {
          perror("Error creating timer:");
        }

   sigset(SIGUSR2, (void (*)()) hdl);

   tval.it_interval.tv_sec  = 2;
   tval.it_interval.tv_nsec = 0;

   tval.it_value.tv_sec  = 2;
   tval.it_value.tv_nsec = 0;

   status = timer_settime(tid, 0, &tval, NULL);
   if (status)
        {
          perror("Error setting timer:");
          printf("status = %d, errno = %d\n", status, errno);
        }

   for ( i = 0; i < 5; i++ ) pause();

Quote:}

--
-------------------------------------------------------------------------------
Paul McRae, Cableshare, Inc., 150 Dufferin Ave., London, ON   N6A 5N6

The Truth is Out There | Linux, Choice of the GNU Generation | Tired or WiRED?
 
 
 

1. timer_create refers to struct sigevent; struct sigevent not availabe unders same conditions as timer_create

Him

time.h in included in c source file. The file does not use the
timer_create function but compiling the file throws a warning:

/opt/WS6U2/SUNWspro/bin/cc semaph.c -D_XPG4_2
"/usr/include/time.h", line 99: warning: dubious tag declaration:
struct sigevent

This is because the declaration of timer_create function gets included
which refers to the structure sigevent. But the structure sigevent
present in sys/siginfo.h included in time.h does not get included as
it is enclosed in a
!defined(_XPG4_2).

Basically the condition under which the declaration of timer_create
gets included and sigevent gets included vary.

time.h
--------------------------------------------------------------------------
#if defined(__EXTENSIONS__) || ((__STDC__ - 0 == 0) && \
                !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))
|| \
                (_POSIX_C_SOURCE > 2)
extern int timer_create(clockid_t, struct sigevent *, timer_t *);
#endif
--------------------------------------------------------------------------

sys/siginfo.h
--------------------------------------------------------------------------
#if (!defined(_POSIX_C_SOURCE) && !defined(_XPG4_2)) || \
        (_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)

struct sigevent {
        int             sigev_notify;   /* notification mode */
        union {
                int     _sigev_signo;   /* signal number */
                void    (*_sigev_notify_function)(union sigval);
        } _sigev_un;
        union sigval    sigev_value;    /* signal value */
        int             _sigev_pad1;
        void            *_sigev_notify_attributes;
        int             _sigev_pad2;
#endif
--------------------------------------------------------------------------

Is there a way to resolve this warning? Should it be resolved since I
am not using timer_create. Should _XOPEN_SOURCE be defined when
_XPG4_2 is defined?. If I define _XOPEN_SOURCE as well this warning
goes off but I am not sure if I am doing the right thing?

Kindly help.

Thanks and Regards,
Mranalini

PS: I am working on Solaris 2.6 and using the Forte 6 Update 2 cc
compiler.

2. DOOM/Games & XFree86 3.1

3. DHCP with SCO ODT 5 and SCO ODT 3?

4. GNome and Enlightenment : slow startup

5. smtp mmdf not working for SCO 5.0 (send ok but not receive)

6. segementation fault; hwclock -s $GMT

7. Q: lp commands do not work for normal user on SCO ODT 3.0 - why??

8. Please help! - Lots of Linux info needed!

9. ODT 3.0 Device Drivers with ODT 5.0?

10. SCO ODT 5.0 - Kernel Panik after Release Supplement 5.0.0.d

11. Info about Process Management in SCO ODT 5.0

12. 3 Screens on SCO ODT 5.0?

13. Looking for FaxServer for SCO ODT 5.0