Fossil SCM

On unix, make sure file descriptor 2 is open and file descriptor 3 is not open at the beginning of main(). The first check helps ensure that a assert() will not accidently overwrite a file. The second check verifies that the is_valid_fd() function used by the first check really works.

drh 2013-08-31 17:19 UTC trunk
Commit 4ef3708d8d646f90c9d1c486cfbb2693f19aea75
1 file changed +3
+3
--- src/main.c
+++ src/main.c
@@ -608,11 +608,14 @@
608608
g.argc++;
609609
g.argv = zNewArgv;
610610
}
611611
zCmdName = g.argv[1];
612612
}
613
+#ifndef _WIN32
613614
if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
615
+ if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open");
616
+#endif
614617
rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
615618
if( rc==1 ){
616619
fossil_fatal("%s: unknown command: %s\n"
617620
"%s: use \"help\" for more information\n",
618621
g.argv[0], zCmdName, g.argv[0]);
619622
--- src/main.c
+++ src/main.c
@@ -608,11 +608,14 @@
608 g.argc++;
609 g.argv = zNewArgv;
610 }
611 zCmdName = g.argv[1];
612 }
 
613 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
 
 
614 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
615 if( rc==1 ){
616 fossil_fatal("%s: unknown command: %s\n"
617 "%s: use \"help\" for more information\n",
618 g.argv[0], zCmdName, g.argv[0]);
619
--- src/main.c
+++ src/main.c
@@ -608,11 +608,14 @@
608 g.argc++;
609 g.argv = zNewArgv;
610 }
611 zCmdName = g.argv[1];
612 }
613 #ifndef _WIN32
614 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
615 if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open");
616 #endif
617 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
618 if( rc==1 ){
619 fossil_fatal("%s: unknown command: %s\n"
620 "%s: use \"help\" for more information\n",
621 g.argv[0], zCmdName, g.argv[0]);
622

Keyboard Shortcuts

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