[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Process Leak after using Session module

Pra Bhandar

5/27/2009 10:38:00 PM

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
--
Posted via http://www.ruby-....

4 Answers

Tim Pease

5/28/2009 3:59:00 PM

0

On Wed, May 27, 2009 at 4:38 PM, Pra Bhandar <pbhandari2050@gmail.com> wrot=
e:
> 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

Robert Klemme

5/28/2009 6:45:00 PM

0

On 28.05.2009 17:58, Tim Pease wrote:
> On Wed, May 27, 2009 at 4:38 PM, Pra Bhandar <pbhandari2050@gmail.com> wrote:

> 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

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestprac...

Pra Bhandar

5/28/2009 8:03:00 PM

0

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 Klemme wrote:
> On 28.05.2009 17:58, Tim Pease wrote:
>> On Wed, May 27, 2009 at 4:38 PM, Pra Bhandar <pbhandari2050@gmail.com> wrote:
>
>> }
>> end
>>
>
> Guessing here as well: maybe bash.close helps.
>
> My 0.02 EUR...
>
> robert

--
Posted via http://www.ruby-....

Robert Klemme

5/28/2009 8:38:00 PM

0

On 28.05.2009 22:02, Pra Bhandar 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. :-)

> Thanks a bunch...

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

Kind regards

robert


--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestprac...