浏览代码

Fixes #32 set stderr non-blocking

Syslog seems to block entering in screen copymode... verbose mode drops
messages allowing pyfcgi to continue.
Yann Weber 5 年前
父节点
当前提交
0ce4c2ddc1
共有 2 个文件被更改,包括 19 次插入2 次删除
  1. 2
    2
      README
  2. 17
    0
      src/logger.c

+ 2
- 2
README 查看文件

@@ -9,10 +9,10 @@ Building & running pyfcgi :
9 9
 	$ ./configure
10 10
 	$ make
11 11
 	# To run foo_pep333.entrypoint() PEP333 application
12
-	$ ./src/pyfcgi -l '127.0.0.1:9000' -S -e foo_pep333 -E entrypoint
12
+	$ ./src/pyfcgi -l '127.0.0.1:9000' -v -e foo_pep333 -E entrypoint
13 13
 or
14 14
 	# To run foo.entrypoint() sending to FCGI python stdout
15
-	$ ./src/pyfcgi -l '127.0.0.1:9000' -S -e foo -E entrypoint -A
15
+	$ ./src/pyfcgi -l '127.0.0.1:9000' -v -e foo -E entrypoint -A
16 16
 
17 17
 
18 18
 configure script determine python flags, libs & includes paths using

+ 17
- 0
src/logger.c 查看文件

@@ -557,9 +557,26 @@ const char* pyfcgi_logger_value_facility(short typ)
557 557
 
558 558
 int pyfcgi_logger_open(pyfcgi_logger_t *logger)
559 559
 {
560
+	int flags;
560 561
 	if(!logger->filename)
561 562
 	{
562 563
 		logger->fd = 2;
564
+		flags = fcntl(logger->fd, F_GETFL);
565
+		if(flags == -1)
566
+		{
567
+			pyfcgi_log(LOG_ERR,
568
+				"Unable to GETFL on stderr",
569
+				strerror(errno));
570
+			return PYFCGI_ERR;
571
+		}
572
+		flags |= O_NONBLOCK;
573
+		if(fcntl(logger->fd, F_SETFL, flags) == -1)
574
+		{
575
+			pyfcgi_log(LOG_ERR,
576
+				"Unable to SETFL on stderr",
577
+				strerror(errno));
578
+			return PYFCGI_ERR;
579
+		}
563 580
 		return 0;
564 581
 	}
565 582
 

正在加载...
取消
保存