#include #include #include "TROOT.h" #include "TFile.h" #include "TH1F.h" #include "TF1.h" using namespace std; static TFile* outfile; static TH1F* hist; void myatexit() { cout<<"---------------------------------------- atexit"<GetListOfFiles()->ls(); if(outfile != NULL) { if(outfile->IsOpen() && !outfile->IsZombie()) { outfile->Print(); hist->Write(); outfile->Close(); } } } int main(int argc, char* argv[]) { atexit(myatexit); outfile = new TFile("atexit.root","recreate"); hist = new TH1F("hist","hist",100,0,100); gDebug = 1; gROOT->GetListOfFiles()->ls(); outfile->Print(); return 0; }