Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-11

Problems with setitimer....

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Judison

Hi all

First excuse my poor english,

I'm trying to use setitimer (man setitimer) to get "alarmed" every X ms under linux... and since we don't have the setitimer and getitimer in RTL yet (Marco van de Voort will include it), I tried to use SysCall, but, it seens that I'm doing something wrong....

I attached the pascal source (test.pas) and a C source that works (ctest.c) (gcc -o ctest ctest.c)

The C test, recieves a signal (SIGALRM) every 50ms, and the Pascal one, does not recieve anything... but, if I:

# killall -ALRM test

the Test recieves it, but, the next time I do this, it prints "Alarm clock" and the program is terminated.

(it all, even with FPC 1.0.6 and 1.1 compiled today from cvs)

TIA
Your friend,
Judison

Anton Tichawa
to Judison

hi, judison!

i enclose some procedures i currently use for setitimer / getitimer. they do
work.

i briefly looked at your code and found 2 possible problems:

1) maybe it's better to use 'sigaction' instead of 'signal'

2) i don't know if it's allowed to do file i/o (WriteLn) within the signal handler.

hth,

anton.

you wrote 25 lines
Hi all First excuse my poor english, I'm trying to use setitimer (man setitimer) to get "alarmed" every X ms under linux... and since we don't have the setitimer and getitimer in RTL yet (Marco van de Voort will include it), I tried to use SysCall, but, it seens that I'm doing something wrong.... I attached the pascal source (test.pas) and a C source that works (ctest.c) (gcc -o ctest ctest.c) The C test, recieves a signal (SIGALRM) every 50ms, and the Pascal one, does not recieve anything... but, if I: # killall -ALRM test the Test recieves it, but, the next time I do this, it prints "Alarm clock" and the program is terminated. (it all, even with FPC 1.0.6 and 1.1 compiled today from cvs) TIA Your friend, Judison
Judison
to Anton Tichawa
i enclose some procedures i currently use for setitimer / getitimer. they do work.

It worked for me, and now I'm happy :)
Thank you very much.

i briefly looked at your code and found 2 possible problems: 1) maybe it's better to use 'sigaction' instead of 'signal'

Yes and No, using SigAction it works fine, using signal, it works, but only 2 times, giving me an "Alarm Clock" and terminating my program.

2) i don't know if it's allowed to do file i/o (WriteLn) within the signal handler.

Under Unix point of view, what else (useful) can I do?

Well, I'll only put a new event in X Event Queue, so my main block wich is blocked waiting X Events, will process this event ;)

Thanks again
Your friend,
Judison