Browse Source

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 years ago
parent
commit
0ce4c2ddc1
2 changed files with 19 additions and 2 deletions
  1. 2
    2
      README
  2. 17
    0
      src/logger.c

+ 2
- 2
README View File

9
 	$ ./configure
9
 	$ ./configure
10
 	$ make
10
 	$ make
11
 	# To run foo_pep333.entrypoint() PEP333 application
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
 or
13
 or
14
 	# To run foo.entrypoint() sending to FCGI python stdout
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
 configure script determine python flags, libs & includes paths using
18
 configure script determine python flags, libs & includes paths using

+ 17
- 0
src/logger.c View File

557
 
557
 
558
 int pyfcgi_logger_open(pyfcgi_logger_t *logger)
558
 int pyfcgi_logger_open(pyfcgi_logger_t *logger)
559
 {
559
 {
560
+	int flags;
560
 	if(!logger->filename)
561
 	if(!logger->filename)
561
 	{
562
 	{
562
 		logger->fd = 2;
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
 		return 0;
580
 		return 0;
564
 	}
581
 	}
565
 
582
 

Loading…
Cancel
Save