Fixed segfault condition in sanei_thread_waitpid.

merge-requests/1/head
Gerhard Jaeger 2003-10-10 13:01:46 +00:00
rodzic 75e7483301
commit fe97c01e62
2 zmienionych plików z 18 dodań i 15 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
2003-10-10 Gerhard Jaeger <gerhard@gjaeger.de> 2003-10-10 Gerhard Jaeger <gerhard@gjaeger.de>
* sanei/sanei_thread.c: Fixed some compilation errors on Darwin and OS/2 * sanei/sanei_thread.c: Fixed some compilation errors on Darwin and OS/2
Fixed segfault condition in sanei_thread_waitpid
2003-10-09 Peter Kirchgessner <peter@kirchgessner.net> 2003-10-09 Peter Kirchgessner <peter@kirchgessner.net>

Wyświetl plik

@ -261,10 +261,9 @@ sanei_thread_waitpid( int pid, int *status )
#else #else
int ls; int ls;
#endif #endif
int result; int result, stat;
if (status) stat = 0;
*status = 0;
DBG(2, "sanei_thread_waitpid() - %d\n", (int)pid); DBG(2, "sanei_thread_waitpid() - %d\n", (int)pid);
#ifdef USE_PTHREAD #ifdef USE_PTHREAD
@ -273,29 +272,32 @@ sanei_thread_waitpid( int pid, int *status )
if( 0 == result ) { if( 0 == result ) {
DBG(2, "* detaching thread\n" ); DBG(2, "* detaching thread\n" );
pthread_detach((pthread_t)pid ); pthread_detach((pthread_t)pid );
if( PTHREAD_CANCELED == ls ) { if( PTHREAD_CANCELED == ls ) {
DBG(2, "* thread has been canceled!\n" ); DBG(2, "* thread has been canceled!\n" );
* status = SANE_STATUS_GOOD; stat = SANE_STATUS_GOOD;
} else { } else {
*status = *ls; stat = *ls;
} }
DBG(2, "* result = %d\n", *status ); DBG(2, "* result = %d (%p)\n", stat, (void*)status );
} }
if (status)
/* should return */ *status = stat;
/* should return pid */
return pid; return pid;
#else #else
result = waitpid( pid, &ls, 0 ); result = waitpid( pid, &ls, 0 );
if((result < 0) && (errno == ECHILD)) { if((result < 0) && (errno == ECHILD)) {
if( status ) stat = SANE_STATUS_GOOD;
* status = SANE_STATUS_GOOD;
result = pid; result = pid;
} else { } else {
if (status) { stat = eval_wp_result( pid, result, ls );
*status = eval_wp_result( pid, result, ls ); DBG(2, "* result = %d (%p)\n", stat, (void*)status );
}
} }
if( status )
*status = stat;
return result; return result;
#endif #endif
} }