/* * General problem handler */ static void interrupted (int sig) { exit_sig = sig; if (exit_flag) { fprintf(stderr, "extra[%d] signal: %d\n", exit_flag, sig); exit_flag++; if (use_threads) { usleep2(250 * 1000); } else if (exit_flag <= 2) { return; } if (rm_flagfile) { unlink(rm_flagfile); rm_flagfile = NULL; } exit(4); } exit_flag++; if (sig == 0) { fprintf(stderr, "caught X11 error:\n"); if (crash_debug) { crash_shell(); } } else if (sig == -1) { fprintf(stderr, "caught XIO error:\n"); } else { fprintf(stderr, "caught signal: %d\n", sig); } if (sig == SIGINT) { shut_down = 1; return; } if (crash_debug) { crash_shell(); } X_UNLOCK; if (icon_mode) { clean_icon_mode(); } /* remove the shm areas with quick=1: */ clean_shm(1); if (sig == -1) { /* not worth trying any more cleanup, X server probably gone */ if (rm_flagfile) { unlink(rm_flagfile); rm_flagfile = NULL; } exit(3); } /* X keyboard cleanups */ delete_added_keycodes(0); if (clear_mods == 1) { clear_modifiers(0); } else if (clear_mods == 2) { clear_keys(); } else if (clear_mods == 3) { clear_keys(); clear_locks(); } if (no_autorepeat) { autorepeat(1, 0); } if (use_solid_bg) { solid_bg(1); } if (ncache || ncache0) { kde_no_animate(1); } stop_stunnel(); if (crash_debug) { crash_shell(); } if (sig) { if (rm_flagfile) { unlink(rm_flagfile); rm_flagfile = NULL; } exit(2); } }
int get_ia_stat(char *hostname, char *username ) { #ifdef NESSIE int connsid, iter, ival, initOpsCompl, newOpsCompl, updated; TIMESTAMP timeStamp, timeStamp2; char expprocReply[ 122 ]; gettimeofday( &timeStamp, NULL); initOpsCompl = getStatOpsCompl(); ival = talk2Acq( hostname, username, READACQHW, "", &expprocReply[ 0 ], sizeof( expprocReply ) ); if (ival < 0) return( -1 ); else connsid = ival; ival = prepare_reply_socket( connsid ); if (ival != 0) { close( connsid ); return( -1 ); } ival = getascii( connsid, &expprocReply[ 0 ], sizeof( expprocReply ) - 1 ); close( connsid ); updated = 0; for (iter = 0; iter < 50; iter++) { /* increased from 10 to 50, July 1997 */ usleep2( 20000 ); /* 20 ms, 0.02 s */ getStatTimeStamp( &timeStamp2 ); newOpsCompl = getStatOpsCompl(); if (cmpTimeStamp( &timeStamp2, &timeStamp ) > 0 && newOpsCompl != initOpsCompl) { updated = 1; break; } } if (updated == 0) return( -1 ); else return( 0 ); #else int connsid, ival; #if defined(WINBRIDGE) && defined(DEBUG) fprintf(stdout, "DEBUG jgw: socket.c get_ia_stat calling poke_acqproc\n"); fprintf(stdout, "DEBUG jgw: socket.c get_ia_stat hostname = %s\n", hostname); fprintf(stdout, "DEBUG jgw: socket.c get_ia_stat username = %s\n", username); fprintf(stdout, "DEBUG jgw: socket.c get_ia_stat cmd = %d\n", READACQHW); #endif ival = poke_acqproc(hostname, username, READACQHW, "1,24,"); if (ival < 0) { return( -1 ); } else connsid = ival; ival = prepare_reply_socket( connsid ); if (ival != 0) { return( -1 ); } memset( &shlk_block, 0, sizeof( struct ia_stat ) ); ival = getbinary( connsid, &shlk_block, sizeof( struct ia_stat ) ); close( connsid ); if (ival > 0) return( 0 ); else return( -1 ); #endif }