X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fbcsignals.C;h=ed50cfb15d9e8ac38c630c3096c9ab2b77fce477;hp=6847fa5cabbccd7598cbf58ac129c578743d35be;hb=7e5a0760f40ff787cc3d93cb7768a901ebe52809;hpb=d348518c261d543e12282d516768d4f446434a42 diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C index 6847fa5c..ed50cfb1 100644 --- a/cinelerra-5.1/guicast/bcsignals.C +++ b/cinelerra-5.1/guicast/bcsignals.C @@ -88,14 +88,14 @@ void BC_Signals::set_catch_segv(bool v) { if( v == trap_sigsegv ) return; if( v ) catch_segv(); else uncatch_segv(); - v = trap_sigsegv; + trap_sigsegv = v; } void BC_Signals::set_catch_intr(bool v) { if( v == trap_sigintr ) return; if( v ) catch_intr(); else uncatch_intr(); - v = trap_sigintr; + trap_sigintr = v; } static void bc_copy_textfile(int lines, FILE *ofp, const char *fmt,...) @@ -109,6 +109,53 @@ static void bc_copy_textfile(int lines, FILE *ofp, const char *fmt,...) fclose(ifp); } +static void bc_list_openfiles(int lines, FILE *ofp, const char *fmt,...) +{ + va_list ap; va_start(ap, fmt); + char bfr[BCTEXTLEN]; vsnprintf(bfr, sizeof(bfr), fmt, ap); + va_end(ap); + DIR *dir = opendir(bfr); + if( !dir ) return; + struct dirent64 *dent; + while( --lines >= 0 && (dent = readdir64(dir)) ) { + const char *fn = dent->d_name; + fprintf(ofp, "%s", fn); + char path[BCTEXTLEN], link[BCTEXTLEN]; + struct stat st; + snprintf(path, sizeof(path), "%s/%s", bfr, fn); + if( !stat(path,&st) ) { + int typ = 0; + if( S_ISREG(st.st_mode) ) typ = ' '; + else if( S_ISDIR(st.st_mode) ) typ = 'd'; + else if( S_ISBLK(st.st_mode) ) typ = 'b'; + else if( S_ISCHR(st.st_mode) ) typ = 'c'; + else if( S_ISFIFO(st.st_mode) ) typ = 'f'; + else if( S_ISLNK(st.st_mode) ) typ = 'l'; + else if( S_ISSOCK(st.st_mode) ) typ = 's'; + if( typ ) fprintf(ofp, "\t%c", typ); + fprintf(ofp, "\tsize %jd", st.st_size); + int len = readlink(path, link, sizeof(link)-1); + if( len > 0 ) { + link[len] = 0; + fprintf(ofp, "\t-> %s", link); + } + } + snprintf(path, sizeof(path), "%sinfo/%s", bfr, fn); + FILE *fp = fopen(path,"r"); int64_t pos; + if( fp ) { + while( fgets(link, sizeof(link), fp) ) { + if( sscanf(link, "pos:%jd", &pos) == 1 ) { + fprintf(ofp, "\tpos: %jd", pos); + break; + } + } + fclose(fp); + } + fprintf(ofp, "\n"); + } + closedir(dir); +} + // Can't use Mutex because it would be recursive static pthread_mutex_t *handler_lock = 0; @@ -208,7 +255,6 @@ static void signal_entry(int signum) BC_Trace::dump_traces(); BC_Trace::dump_locks(); BC_Trace::dump_buffers(); - BC_Trace::dump_shm_stats(); BC_Trace::delete_temps(); // Call user defined signal handler @@ -401,6 +447,8 @@ static void handle_dump(int n, siginfo_t * info, void *sc) } fprintf(fp,"\nVERSION:\n"); bc_copy_textfile(INT_MAX, fp,"/proc/version"); fprintf(fp,"\nMEMINFO:\n"); bc_copy_textfile(INT_MAX, fp,"/proc/meminfo"); + fprintf(fp,"\nSTATUS:\n"); bc_copy_textfile(INT_MAX, fp,"/proc/%d/status",pid); + fprintf(fp,"\nFD:\n"); bc_list_openfiles(INT_MAX, fp,"/proc/%d/fd", pid); fprintf(fp,"\nMAPS:\n"); bc_copy_textfile(INT_MAX, fp,"/proc/%d/maps",pid); char proc_mem[64]; if( tid > 0 && tid != pid )