696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
|
** If this happens, and a subsequent open() of a database returns file
** descriptor 2, and then an assert() fires and writes on fd 2, that
** can corrupt the data file. To avoid this problem, make sure open()
** will never return file descriptor 2 or less. */
if( !is_valid_fd(2) ){
int nTry = 0;
int fd = 0;
while( !is_valid_fd(2)
&& (nTry++)<2
&& (fd = open("/dev/null",O_WRONLY))>=0 && fd<2 ){}
if( fd<2 && !is_valid_fd(2) ){
g.cgiOutput = 1;
g.httpOut = stdout;
g.fullHttpReply = !g.isHTTP;
fossil_fatal("file descriptor 2 is not open");
}
}
#endif
rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
if( rc==1 ){
#ifdef FOSSIL_ENABLE_TH1_HOOKS
if( !g.isHTTP && !g.fNoThHook ){
|
|
<
>
|
>
>
>
|
|
>
|
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
|
** If this happens, and a subsequent open() of a database returns file
** descriptor 2, and then an assert() fires and writes on fd 2, that
** can corrupt the data file. To avoid this problem, make sure open()
** will never return file descriptor 2 or less. */
if( !is_valid_fd(2) ){
int nTry = 0;
int fd = 0;
int x = 0;
do{
fd = open("/dev/null",O_WRONLY);
if( fd>=2 ) break;
if( fd<0 ) x = errno;
}while( nTry++ < 2 );
if( fd<2 ){
g.cgiOutput = 1;
g.httpOut = stdout;
g.fullHttpReply = !g.isHTTP;
fossil_fatal("file descriptor 2 is not open. (fd=%d, errno=%d)",
fd, x);
}
}
#endif
rc = name_search(zCmdName, aCommand, count(aCommand), FOSSIL_FIRST_CMD, &idx);
if( rc==1 ){
#ifdef FOSSIL_ENABLE_TH1_HOOKS
if( !g.isHTTP && !g.fNoThHook ){
|