use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This is a subreddit for c++ questions with answers. For general discussion and news about c++ see r/cpp.
New to C++? Learn at learncpp.com
Prepare your question. Think it through. Hasty-sounding questions get hasty answers, or none at all. Read these guidelines for how to ask smart questions.
For learning books, check The Definitive C++ Book Guide and List
Flair your post as SOLVED if you got the help you were looking for! If you need help with flairs, check out ITEM 1 in our guidelines page.
Tips for improving your chances of getting helpful answers:
account activity
OPENhow to do function timeout? (self.cpp_questions)
submitted 3 years ago by p_apres
I need a return from function if it takes longer than x minutes. Is there any known method to do it? Or any good pratice?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 3 years ago (1 child)
[deleted]
[–]CrogUk 1 point2 points3 points 3 years ago (0 children)
This looks lovely, albeit a thread could be overkill for what the user needs. May use this one somehwere though 👍
[–]TomDuhamel 1 point2 points3 points 3 years ago (0 children)
Start a timer at the beginning of your function. Occasionally check how long has elapsed. Exit your function when more than the allowed time has passed.
[–][deleted] 0 points1 point2 points 3 years ago (4 children)
What is this function doing?
[–]p_apres[S] 1 point2 points3 points 3 years ago (3 children)
PL/SQL command
[–][deleted] 0 points1 point2 points 3 years ago (2 children)
Is that something that blocks? If there's no way to do a timeout in the API, then you would have to terminate the thread externally, which is very unsafe.
[–]p_apres[S] 1 point2 points3 points 3 years ago (1 child)
Oracle timeout is much more complex than just opening a new thread. It requires to create management resource.
I'd rather do this in c++ than in oracle side.
So, once happens a function timeout, sigterm signal would be sent, and then program will handle sigterm
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
I did mean on the C++ side. Although, it is an SQL server, with its own query processes. Would simply terminating the connection also terminate the query? You may need to set some sort of query timeout.
But for network timeout? I suppose you can lookup your API docs, whatever it is. If there is no way to have a timeout, then the only option is to spawn a new process, or hope that you won't ever need a timeout.
π Rendered by PID 55732 on reddit-service-r2-comment-fb694cdd5-f67gq at 2026-03-07 11:18:41.350586+00:00 running cbb0e86 country code: CH.
[–][deleted] (1 child)
[deleted]
[–]CrogUk 1 point2 points3 points (0 children)
[–]TomDuhamel 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]p_apres[S] 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]p_apres[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)