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.
You could fork a child that would do the read and then in the parent you could use sleep to wait for your timeout length and then just kill the child if it's still waiting. Off the top of my head I don't remember how the python code would look but it's pretty simple.
Hell, it doesn't exit if sys.exit() is called from the function called from the Timer. Is that because of the call being in another thread? or because the readline() will refuse to quit?
Threading.Timer() is not what you want because it executes a command after some time. I was thinking you could fork a child and kill it after the timeout but that doesn't work because in order to get values back from the child you need to use a pipe() and os.read(), but os.read() is a blocking call...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.