Fossil SCM

If file descriptor 2 is not open, try twice to open it. If it still is not open, just continue on, because presumably it won't open on any subquent open() system call.

drh 2015-02-07 16:59 trunk
Commit a3ade265680a8488627275fb8beafebedd136add
1 file changed +6 -2
+6 -2
--- src/main.c
+++ src/main.c
@@ -689,12 +689,16 @@
689689
g.argv = zNewArgv;
690690
}
691691
zCmdName = g.argv[1];
692692
}
693693
#ifndef _WIN32
694
- if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
695
- /* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
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
+ }
696700
#endif
697701
rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
698702
if( rc==1 ){
699703
#ifdef FOSSIL_ENABLE_TH1_HOOKS
700704
if( !g.isHTTP && !g.fNoThHook ){
701705
--- src/main.c
+++ src/main.c
@@ -689,12 +689,16 @@
689 g.argv = zNewArgv;
690 }
691 zCmdName = g.argv[1];
692 }
693 #ifndef _WIN32
694 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
695 /* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
 
 
 
 
696 #endif
697 rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
698 if( rc==1 ){
699 #ifdef FOSSIL_ENABLE_TH1_HOOKS
700 if( !g.isHTTP && !g.fNoThHook ){
701
--- src/main.c
+++ src/main.c
@@ -689,12 +689,16 @@
689 g.argv = zNewArgv;
690 }
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 #ifdef FOSSIL_ENABLE_TH1_HOOKS
704 if( !g.isHTTP && !g.fNoThHook ){
705

Keyboard Shortcuts

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