question about fgets

i'm writing a program as a project for a class, and i've gotten it working, but there's one thing i'd like to try to fix:

the program is set to catch the SIGTSTP signal (ctrl+z) and is supposed to lock and only unlock when the user enters the correct username and password. in the main function loop i used fgets in order to get the user input.

eg. fgets(str_input,MAX_STRLEN,stdin);

the problem is that when ctrl+z is pressed, the program is supposed to prompt the user for a username and password. however, because fgets is waiting for input, the user must press enter before it will prompt for the username and password.

i was just wondering if there was a way around this. maybe, make fgets cancel or error out when ctrl+z is pressed. any help is appreciated.

thanks!

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion