خرید بک لینک

Vote count: 2

I have a basic sketch of implementing a multithreaded web proxy:

FILE *proxy_log_file;

static void
SIGUSR1_handler(int sig)
{
    (void)sig;
    fflush(proxy_log_file);
}

int
main(int argc, char **argv)
{
    proxy_log_file = fopen("proxy.log", "a");
    Signal(SIGUSR1, SIGUSR1_handler);
}

The idea is that network admins can flush buffered log entries to a log file by using the kill command to send a SIGUSR1 signal to the web proxy. However, I'm not sure it's a good idea to call fflush inside the signal handler. I know fflush is thread-safe but don't think it's async-signal-safe. What concurrency problem could arise from calling fflush inside a signal handler of a multithreaded?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 12 ارديبهشت 1395 ساعت: 2:29

صفحه بندی