Process Leak after using Session module

Hi,

This script has a process leak with a bash session being left open every
time I run it. I can’t find a way to close the bash object after I am
done. Docs don’t explicitly don’t cover this… or I am missing something
simple. Can anyone shed some light on this or point to docs that I may
not be aware of? I looked at the readme provided by Sessions module
authors so far.

Thanks in advance.

Prakash

bash = Session::Shell.new

oratab_file = Oratab()
ofile = File.open(oratab_file, “r”)
############################################################

Looping through all lines

############################################################
bash.execute “>instancestatus-output.txt”
ofile.each { |oratab_line|
if oratab_line =~ /^\s+/
else
if oratab_line =~ /^#/
else
if oratab_line =~ /^+/
else
db_str = db_and_flag(oratab_line)
db_arr = db_str.split(",")
db_name = db_arr[0]
puts db_name

       #########################################################
       # Make calls to the right database calls right here
       ##########################################################
       bash.execute "echo #{db_name}:>>instancestatus-output.txt"
       bash.execute "InstanceStatus.sh #{db_name}", 1 => STDOUT, 2

=> STDERR do |out,err|
puts out if out
puts err if err
end
##########################################################
# End of loop for bash.execute
##########################################################
end
end
end

/* end of the ofile.each statement */

#################################################################

#################################################################
}
end

On Wed, May 27, 2009 at 4:38 PM, Pra B. [email protected]
wrote:

Hi,

This script has a process leak with a bash session being left open every
time I run it. I can’t find a way to close the bash object after I am
done. Docs don’t explicitly don’t cover this… or I am missing something
simple. Can anyone shed some light on this or point to docs that I may
not be aware of? I looked at the readme provided by Sessions module
authors so far.

Just a guess here, but try closing your oratab_file descriptor. The
bash shell will usually hang around if there are open file descriptors
or child processes running. If closing the file descriptor does not
work, then try looking for open sockets or running children.

oratab_file = Oratab()
File.open(oratab_file, ‘r’) do |ofile|
bash.execute “>instancestatus-output.txt”
ofile.each { |oratab_line|

}
end

Blessings,
TwP

On 28.05.2009 17:58, Tim P. wrote:

On Wed, May 27, 2009 at 4:38 PM, Pra B. [email protected] wrote:

}
end

Guessing here as well: maybe bash.close helps.

My 0.02 EUR…

robert

On 28.05.2009 22:02, Pra B. wrote:

That was it! Your .02 EUR was wprth a lot for me today. Is there some
documentation where I could have found that bit of nugget?

I have no idea: I had this idea of #close and briefly tried to find
documentation but hit only source code. So I voiced it nevertheless.

The basic reasoning was, if you open the session with Session.new it
probably also needs to be closed. :slight_smile:

Thanks a bunch…

You’re welcome! I’m glad my wild guess was of help.

Kind regards

robert

That was it! Your .02 EUR was wprth a lot for me today. Is there some
documentation where I could have found that bit of nugget?

Thanks a bunch…

Robert K. wrote:

On 28.05.2009 17:58, Tim P. wrote:

On Wed, May 27, 2009 at 4:38 PM, Pra B. [email protected] wrote:

}
end

Guessing here as well: maybe bash.close helps.

My 0.02 EUR…

robert