Fossil SCM

Improvements to detections and attempted mitigation of the file-descriptor 2 not open problem sometimes seen with stunnel4.

drh 2015-02-07 19:48 trunk
Commit bd60090134eead7237be4e9d409be2ece0b80e42
1 file changed +3 -2
+3 -2
--- src/main.c
+++ src/main.c
@@ -691,12 +691,13 @@
691691
zCmdName = g.argv[1];
692692
}
693693
#ifndef _WIN32
694694
/* Make sure open() will not return file descriptor 2. */
695695
{ int nTry = 0;
696
- while( !is_valid_fd(2) && nTry++ < 2 ){
697
- open("/dev/null", O_WRONLY);
696
+ while( !is_valid_fd(2) && nTry++ < 2 && open("/dev/null",O_WRONLY)>0 ){}
697
+ if( !is_valid_fd(2) ){
698
+ fossil_fatal("file descriptor 2 is not open");
698699
}
699700
}
700701
#endif
701702
rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
702703
if( rc==1 ){
703704
--- src/main.c
+++ src/main.c
@@ -691,12 +691,13 @@
691 zCmdName = g.argv[1];
692 }
693 #ifndef _WIN32
694 /* Make sure open() will not return file descriptor 2. */
695 { int nTry = 0;
696 while( !is_valid_fd(2) && nTry++ < 2 ){
697 open("/dev/null", O_WRONLY);
 
698 }
699 }
700 #endif
701 rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
702 if( rc==1 ){
703
--- src/main.c
+++ src/main.c
@@ -691,12 +691,13 @@
691 zCmdName = g.argv[1];
692 }
693 #ifndef _WIN32
694 /* Make sure open() will not return file descriptor 2. */
695 { int nTry = 0;
696 while( !is_valid_fd(2) && nTry++ < 2 && open("/dev/null",O_WRONLY)>0 ){}
697 if( !is_valid_fd(2) ){
698 fossil_fatal("file descriptor 2 is not open");
699 }
700 }
701 #endif
702 rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
703 if( rc==1 ){
704

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button