Running a timeout function in the background

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have a function:
int waiting()
fd_set input_set;
struct timeval timeout;
int ready_for_reading = 0;
int read_bytes = 0;
FD_ZERO(&input_set );
FD_SET(0, &input_set);
timeout.tv_sec = WAIT; // WAIT seconds
timeout.tv_usec = 0; // 0 milliseconds
printf("^[[10;53H^[[1;34;44m LOGIN TO BBS ^[[0;37m", WAIT);
printf("^[[11;53H^[[34;46m apply to bbs ^[[0;37m", WAIT);
printf("^[[12;53H^[[34;46m page sysop ^[[0;37m", WAIT);
printf("^[[13;53H^[[34;46m logout of bbs ^[[0;37m", WAIT);
printf("n", WAIT);
ready_for_reading = select(1, &input_set, NULL, NULL, &timeout);
if (ready_for_reading == -1)
return -1;
if (ready_for_reading)
else
exit(1);
return 0;
It times out, like it should, The problem is that it only works when the user doesn't input anything. I'd like it to work regardless of if the user inputs anything. Also, I'd like to run this function in the background. Is that possible?
c timeout
add a comment |Â
up vote
0
down vote
favorite
I have a function:
int waiting()
fd_set input_set;
struct timeval timeout;
int ready_for_reading = 0;
int read_bytes = 0;
FD_ZERO(&input_set );
FD_SET(0, &input_set);
timeout.tv_sec = WAIT; // WAIT seconds
timeout.tv_usec = 0; // 0 milliseconds
printf("^[[10;53H^[[1;34;44m LOGIN TO BBS ^[[0;37m", WAIT);
printf("^[[11;53H^[[34;46m apply to bbs ^[[0;37m", WAIT);
printf("^[[12;53H^[[34;46m page sysop ^[[0;37m", WAIT);
printf("^[[13;53H^[[34;46m logout of bbs ^[[0;37m", WAIT);
printf("n", WAIT);
ready_for_reading = select(1, &input_set, NULL, NULL, &timeout);
if (ready_for_reading == -1)
return -1;
if (ready_for_reading)
else
exit(1);
return 0;
It times out, like it should, The problem is that it only works when the user doesn't input anything. I'd like it to work regardless of if the user inputs anything. Also, I'd like to run this function in the background. Is that possible?
c timeout
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a function:
int waiting()
fd_set input_set;
struct timeval timeout;
int ready_for_reading = 0;
int read_bytes = 0;
FD_ZERO(&input_set );
FD_SET(0, &input_set);
timeout.tv_sec = WAIT; // WAIT seconds
timeout.tv_usec = 0; // 0 milliseconds
printf("^[[10;53H^[[1;34;44m LOGIN TO BBS ^[[0;37m", WAIT);
printf("^[[11;53H^[[34;46m apply to bbs ^[[0;37m", WAIT);
printf("^[[12;53H^[[34;46m page sysop ^[[0;37m", WAIT);
printf("^[[13;53H^[[34;46m logout of bbs ^[[0;37m", WAIT);
printf("n", WAIT);
ready_for_reading = select(1, &input_set, NULL, NULL, &timeout);
if (ready_for_reading == -1)
return -1;
if (ready_for_reading)
else
exit(1);
return 0;
It times out, like it should, The problem is that it only works when the user doesn't input anything. I'd like it to work regardless of if the user inputs anything. Also, I'd like to run this function in the background. Is that possible?
c timeout
I have a function:
int waiting()
fd_set input_set;
struct timeval timeout;
int ready_for_reading = 0;
int read_bytes = 0;
FD_ZERO(&input_set );
FD_SET(0, &input_set);
timeout.tv_sec = WAIT; // WAIT seconds
timeout.tv_usec = 0; // 0 milliseconds
printf("^[[10;53H^[[1;34;44m LOGIN TO BBS ^[[0;37m", WAIT);
printf("^[[11;53H^[[34;46m apply to bbs ^[[0;37m", WAIT);
printf("^[[12;53H^[[34;46m page sysop ^[[0;37m", WAIT);
printf("^[[13;53H^[[34;46m logout of bbs ^[[0;37m", WAIT);
printf("n", WAIT);
ready_for_reading = select(1, &input_set, NULL, NULL, &timeout);
if (ready_for_reading == -1)
return -1;
if (ready_for_reading)
else
exit(1);
return 0;
It times out, like it should, The problem is that it only works when the user doesn't input anything. I'd like it to work regardless of if the user inputs anything. Also, I'd like to run this function in the background. Is that possible?
c timeout
c timeout
asked 42 mins ago
ignatius
12339
12339
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475118%2frunning-a-timeout-function-in-the-background%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password