This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Problem with sigaction / SIGALRM / x86_64 arch.
Alright I've done a tiny script that generate a test case :
Just paste the following snippet into a file named "test-sigalrm-pack.sh"
Shell execute this script, it'll generate two files :
* tst-sigalrm.cpp : the test case source.
* tst-sigalrm-build : the test case build script.
Note that in order to link statically, I had to 'hack' my install,
creating a symbolic directory to access glibc. This might
differs on several distros. Btw, I'd be happy to know how to
do this universally... Without 'sys hack'...
(See note in the build script, at the linking step...)
Thank you,
Garry.
------------------ SCRIPT START -----------------------------
#!/bin/sh
#test-sigalrm-pack.sh
# 64bit sigalrm segmentation fault test case package...
echo " * Generating source..."
cat >tst-sigalrm.cpp <<TESTSRC
//tst-sigalrm.cpp
#include <stdio.h>
#include <unistd.h>
#include <wait.h>
#include <sys/time.h>
typedef void* pvoid;
namespace{
volatile unsigned int alarmed =0;
struct sigaction action,oldAction;
void _onAlarmSignal(int signal,siginfo_t* sigInfo,pvoid pUContext) {
printf("Tick !\n");
}
void _registerSignal() {
action.sa_flags =SA_SIGINFO;
action.sa_sigaction =_onAlarmSignal;
action.sa_restorer =NULL;
sigemptyset(&action.sa_mask);
sigaction(SIGALRM,&action,&oldAction);
}
void _startTimer() {
itimerval value;
value.it_interval.tv_sec =0;
value.it_interval.tv_usec =100;
value.it_value =value.it_interval;
setitimer(ITIMER_REAL,&value,NULL);
}
}
int main(int argc,const char **argv) {
_registerSignal();
_startTimer();
do ; while(alarmed<10);
return 0;
}
TESTSRC
echo " * Generating build script..."
cat >tst-sigalrm-build <<TESTBUILD
#!/bin/sh
#Custom build of the sigalrm test case:
echo " * Build source..."
cc -c -o "tst-sigalrm.o" -fpermissive -g3 -ggdb -w -D _DEBUG "tst-sigalrm.cpp"
#Custom link the test case:
#
# In order to link I need first to make this link on my system,
# this is because most distros just forget about static link.
# If anybody has a better idea for this :)... (Something that could
# work on any distro without 'hacking' the install...)
#
# /usr/lib64/gcclib -> gcc/x86_64-slackware-linux/4.4.3
#
#
echo " * Linking..."
ld -static -L "/usr/lib64/" -o "tst-sigalrm" \\
/usr/lib64/crt1.o /usr/lib64/crti.o \\
/usr/lib64/gcclib/crtbegin.o \\
"tst-sigalrm.o" \\
-L/usr/lib64/gcclib \\
-\\( -lgcc -lstdc++ -lgcc_eh -lm -lc -\\) \\
/usr/lib64/gcclib/crtend.o \\
/usr/lib64/crtn.o
TESTBUILD
chmod a+x "tst-sigalrm-build"
------------------------ SCRIPT END --------------------------
On Mon, Apr 12, 2010 at 10:40 AM, Carlos O'Donell
<carlos@systemhalted.org> wrote:
> On Mon, Apr 12, 2010 at 3:05 AM, Garry Iglesias
> <garry.iglesias@gmail.com> wrote:
>> Hope I didn't bother you, and, of course, that someone could give me
>> some enlightenment ;).
>
> You need to write a test case showing an example of what your system does.
>
> Without a test case it is difficult for the community to comment on
> your problem.
>
> Cheers,
> Carlos.
>