ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
//
// this describes the asynchronous notification to be posted
// upon this timer's expiration:
//
// - use signals
// - send SIGRTMIN
// - send extra data consisting of a pointer back to the timer ID
// cannot pass the timer ID itself because we haven't created it
// yet.
//
// Signal Handler doesnot return to the calling i.e "after" is not printed. WHY?
if( launchThread() == FALSE)
{
printf("Failed to launch thread.\n");
return 1;
}
// If I call thread_proc (dont create thread) and comment launchThread, I get the correct output
//th_proc();
printf(" in main\n");
while(1)
{
sleep(100);
}
}
My Makefile:
all:
cc -g -pthread -lrt -o try4.o try4.c
clean:
rm -f try4.o
printf doesn't automatically print to the console. Printf buffers its output, and when the buffer is full, or a certain amount of time has elapsed then it outputs its buffer to the screen. Use fprintf(stderr, "Mystring %d", i); instead.
Oh, and you do know that when you call an exit(0); it will exit your program, not the thread. (Someone correct me if I am wrong about this, but I REALLY don't think I am). Use return instead.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.