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
you may try to use the read() system call instead of fgets ?