Getting Process Name from root?

IS there a way to get the current process name from root? I would have thought there would be something in TSystem, but I did not see it.
Thanks!
Ed

Hi Ed,

Try TApplication::Argv() / TApplication::Argc():

int argc = gApplication->Argc(); char **argv = gApplication->Argv(); for (int i=0; i<argc;++i) { std::cout << "argv[" << i << "]: " << argv[i] << std::endl; } (the process name is argv[0])

Cheers, Bertrand.

Sadly, that does not work for a standalone application - gApplication->Argc() returns 0. Argv[0] is “root” when the application is a dll loaded into root…
Ed

Well, if the dll is loaded into root, then root is the name of the main process (or did I miss something?)… What else would you expect in this case?
And BTW, I just tried a standalone application on Windows, and it properly returns the application name.

Cheers, Bertrand.

Hi Bertrand,
I agree with you - if dll is loaded into root, then root is the proper application name.

My stand-alone application has all the root initialization done in a class constructor:CSummary::CSummary() { fStopwatch = new TStopwatch; if(bNo) TTree *pt = new TTree(); if(bNo) TPad *pp = new TPad(); m_fpOut=0; m_pPath=0; gROOT->SetBatch(); TApplication *pApp = new TApplication("RhitCrawler",0,0); fTotal = new Int_t [5]; memset(fTotal,0,5*sizeof(Int_t)); fDelim = 0; } I added the code you suggested, immediately after the TApplication *pApp=… line and argc is zero… I wrote this ages ago and do not know what gROOT->SetBatch() even does… (I am currently using 5.34/01)

Thanks,
Ed

Oh yes, this obviously cannot work, since argc and argv are usually passed to the TApplication constructor…
Then I’m afraid you will have to use a non-ROOT (and non-portable) way of getting this information (or use the standard way of using the ROOT classes :wink: )
And gROOT->SetBatch() put ROOT in batch mode (without GUI/graphics)

Cheers, Bertrand.

Try to modify your “main” routine: int main(int argc, char **argv) { TApplication *pApp = new TApplication("RhitCrawler", &argc, argv); // ...

What about

nxmnpg.com/3/getprogname