* usage ./strobe [frequency]
*/
+//#define __WIN32__
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
+#ifndef __WIN32__
+ #include <fcntl.h>
+#else
+ #include <windows.h>
+#endif
void signal_handler(int signo) {
if(signo == SIGTERM || signo == SIGINT || signo == SIGQUIT) {
fputs(state_a, stdout);
fflush(stdout);
usleep(half_interval);
+ #ifndef __WIN32__
+ int fflags = fcntl(fileno(stdin), F_GETFL, 0);
+ fcntl(fileno(stdin), F_SETFL, fflags | O_NONBLOCK);
+ while(getchar()) puts(".");
+ fcntl(fileno(stdin), F_SETFL, fflags);
+ #else
+ //WARNING! Somehow implement FILE_FLAG_OVERLAPPED & FILE_FLAG_NO_BUFFERING support on windows
+ #endif
if(argc > 2) getchar(); //interactive strobe
fputs(state_b, stdout);
fflush(stdout);