Re: gSystem->Exec and background processes

From: Paul Russo <>
Date: Tue, 12 Jul 2005 18:00:21 -0500


This is a problem with the way root is handling the terminal input. Fortunately there is a workaround:

root [0] gSystem->Exec("root -q dummyloop.C < /dev/zero &")

The changes are:

  1. You should give root the -q option to prevent the second copy of root from prompting you for more input.
        You may also want to give the -l option to prevent
        the second copy of root from putting up the logo

     2. You do not need to quote the macro filename (you can
        if you want to, but it is not necessary).

     3. Redirecting standard input to come from /dev/zero
        prevents root from reading an end-of-file indicator
        from the detached terminal in the gSystem->ProcessEvents()
        call in your macro.  It was this end-of-file indicator
        which caused the second copy of root to exit too soon.

We should be able to fix the underlying problem in the next version of root so this workaround will not be necessary in the future.

--------<original message follows>

Hi, I'm trying to upgrade my code to root-4.04/02 on
"Scientific Linux CERN Release 3.0.5 (SL)".
"gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)"

I found a problem while trying to run another root process with the command "gSystem->Exec".
I attach a simple macro (dummyloop.C) as an example:

[my_shell]$ root
root [0] gSystem->Exec("root \"dummyloop.C\"&")

The process starts, but it is immediately killed: here is the output of the "ps ux | grep root" command:

user 23011  0.0  0.1  3468 1264  pts/6  S 19:17 0:00 root
user 23012  3.0  2.4 45000 24988 pts/6  S 19:17 0:00 /usr/local/root/bin/root.exe -splash
user 23019  1.0  0.1  3464 1256  pts/6  S 19:17 0:00 root -q dummyloop.C
user 23020 22.0  0.0     0    0  pts/6  Z 19:17 0:00 [root.exe <defunct>]

This does not happen if I run the process using the command (without the

root [0] gSystem->Exec("root \"dummyloop.C\"")

Anyway I need to use the "&" in order to keep on working.

I did not find the problem in root-3.10/02. Is there any way to do this in root-4.04?

Thanks in advance.

--------<copy of dummyloop.C follows>

for(Int_t i=0;i<20;i++){
  TCanvas *c1 = new TCanvas();
  cout << "ciao " << i << endl;


Received on Wed Jul 13 2005 - 01:00:29 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:10 MET