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.
Commit
a3ade265680a8488627275fb8beafebedd136add
Parent
dd51f09a390e556…
1 file changed
+6
-2
+6
-2
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -689,12 +689,16 @@ | ||
| 689 | 689 | g.argv = zNewArgv; |
| 690 | 690 | } |
| 691 | 691 | zCmdName = g.argv[1]; |
| 692 | 692 | } |
| 693 | 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"); */ | |
| 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 | + } | |
| 696 | 700 | #endif |
| 697 | 701 | rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx); |
| 698 | 702 | if( rc==1 ){ |
| 699 | 703 | #ifdef FOSSIL_ENABLE_TH1_HOOKS |
| 700 | 704 | if( !g.isHTTP && !g.fNoThHook ){ |
| 701 | 705 |
| --- 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 |