Scanf with Signals
Posted
by jreid42
on Stack Overflow
See other posts from Stack Overflow
or by jreid42
Published on 2010-03-25T03:14:04Z
Indexed on
2010/03/25
3:23 UTC
Read the original article
Hit count: 513
I have a signal that blocks SIGINT and basically says "Sorry, you can't quit.\n"
The issue is this can occur during a scanf.
When this occurs during a scanf, scanf takes in the printf as input.
How can I do a printf that will cause scanf to basically hit the enter key automatically. I don't care that I am getting bad input. I just want to programatically finish that scanf with a printf or something else.
Process:
scanf("get stuff") -> User is able to enter stuff in.
-> SIGINT occurs and goes to my handler.
-> Handler says "Blah blah blah" to stdout.
-> Scanf has taken this blah blah blah and is waiting for more input.
How do I make it so that when I return scanf is finished (don't care what it has gathered I just want it to continue without user help).
© Stack Overflow or respective owner