Could someone try a short program for me, please?

Simon Willcocks simon.willcocks at t-online.de
Fri Oct 8 04:01:11 PDT 2010


Hi,

I've not been keeping up with the developments on LFS for the last couple of
years, but now I'm trying to get the latest kernel and glibc to run because
I've run into a rather nasty problem with a program hanging.

I've boiled it down to the following which generally hangs after a few
seconds when the output is piped into "grep -n Tick" (on a dual core system
with kernel 2.6.32.6 and glibc-2.5.1).  Does anyone here have a more
up-to-date kernel they could try it with to see if I'm barking up the wrong
tree?  When it hangs, if you debug the process it shows it to be stopped in
a futex system call (240).

Sorry if this is the wrong place to ask!

TIA,
Simon

#include <signal.h>
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>

#include <stdint.h>

static void alrm_action( int code, siginfo_t *info, void *p )
{
    fprintf( stderr, "Tick" );
}

int main()
{
    struct sigaction action = { .sa_sigaction = alrm_action, .sa_flags = SA_SIGINFO };
    sigaction( SIGALRM, &action, 0 );

    int microseconds = 10000; // 1cs

    struct itimerval timer_val = { 
        .it_interval = { .tv_sec = microseconds / 1000000, .tv_usec = microseconds % 1000000 },
        .it_value = { .tv_sec = microseconds / 1000000, .tv_usec = microseconds % 1000000 },
    };
    struct itimerval old_val;

    setitimer( ITIMER_REAL, &timer_val, &old_val );

    int x = 0;
    while (1) {
        fprintf( stderr, "+" );
        if (x-- == 0)
        {
            fprintf( stderr, "\n" );
            x = 100;
        }
    }

    return 0;
}

-- 
ROLF - The RISC OS Look and Feel on Linux.
http://ro-lookandfeel.blogspot.com/
http://sourceforge.net/projects/ro-lf/



More information about the lfs-chat mailing list