|
Boost : |
From: Scott Zhang (macromarship_at_[hidden])
Date: 2023-12-20 15:27:35
Dear All:
I have been using boost over 10+ years. The asio library work
quite well along with document.
Today I get a problem:
My development environment:
gcc 4.7.3 OABI
Linux 2.6.15
boost 1.63
The code looks like below:
void myTask(const char *text)
{
sleep(5);
/*for(;;)
{
//sleep(1);
}*/
cout<<"text is "<<text<<endl;
// cout<<"out"<<endl;
}
boost::asio::io_service ioService;
ioService.post(boost::bind(myTask,"hello"));
ioService.run();
I get 2 problems:
1. If I run program as above, the mytask get executed correctly, but
as soon as it returns, the program get "illegal instruction", and
program dies.
If I call myTask directly, then everything is ok.
So what's wrong with io_service.post
2. If I run ioservice within thread using
threadpool.create_thread(
boost::bind(&boost::asio::io_service::run, &ioService)
Then after myTask executed, I get "Killed", using strace says program
get SIGKILL.
As the test code is so simple, I can't tell where goes wrong.
I also noticed, if I don't call io_service.post, everything looks ok.
And the threads, in linux ps, shows as many processes.
I reread the document of asio 1.63, it says had beed tested against
linux 2.4 and 2.6 kernel. so it should be ok.
Please help. Thanks.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk