Process Leak after using Session module

P

Pra Bhandar

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
 
T

Tim Pease

Hi,

This script has a process leak with a bash session being left open every
time I run it. =A0I 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 =3D Oratab()
File.open(oratab_file, 'r') do |ofile|
bash.execute ">instancestatus-output.txt"
ofile.each { |oratab_line|
...
}
end


Blessings,
TwP
 
R

Robert Klemme

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

Guessing here as well: maybe bash.close helps.

My 0.02 EUR...

robert
 
P

Pra Bhandar

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...
 
R

Robert Klemme

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. :)
Thanks a bunch...

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

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] session-2.4.0 0
memory leak 26
Threads, Queues and possible memory leak 3
[ANN] session-2.1.8 3
FFI Memory Leak 4
Memory leak 8
Ruby application session parameters 0
Timeout error using Find module 3

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top