package sample; use strict; use DBI; my $count = 0; sub showtime () { print "Starting loop \n"; #while ( $count < 50 ) { $count++; print ("Connecting to DB \n"); # Modify sid, user, password values. my $dbh = DBI->connect("DBI:Oracle:host=localhost;port=1521;sid=syno",'temipsyno','temipsyno',{PrintError => 1, RaiseError => 1, ora_envhp => 0}); #my $cmd = "grep VmRSS /proc/$$/status"; # Check no. of fd's after connection to db. #my $cmd = "ls -l /proc/$$/fd | grep ocius"; #print `$cmd`; sleep(1); print ("Disconnecting from DB \n"); $dbh->disconnect or warn "Disconnection failed: $DBI::errstr\n"; #} print "Ending script \n"; } 1; #### #!/usr/local/bin/perl use threads; use sample; $ENV{'ORACLE_HOME'} = '/usr/opt/oracle'; sub worker() { my $count = 0; # Make it do some work (open and close DB 10 times). while ( $count < 2 ) { sample::showtime(); $count = $count + 1 ; #my $cmd = "ls -l /proc/$$/fd | grep ocius"; #print threads -> self() -> tid() . " : " . `$cmd` ; sleep 3 } } my $nthreads = 5; for ( 1..$nthreads ) { threads->create(\&worker); } foreach my $thr (threads->list() ) { $thr->join(); } print ("Check no. of fd's for ocius.msb using lsof -p $$. Sleeping 30s \n"); print ("If no. of fd's > 0, then why there is still fd's not closed even after" . " threads have exited \n"); sleep(30); #### ./scr1 #### Starting loop Connecting to DB Starting loop Connecting to DB Starting loop Connecting to DB Starting loop Connecting to DB Starting loop Connecting to DB Disconnecting from DB Ending script Disconnecting from DB Ending script Disconnecting from DB Ending script Disconnecting from DB Ending script Disconnecting from DB Ending script Starting loop Connecting to DB Starting loop Connecting to DB Starting loop Connecting to DB Starting loop Connecting to DB Starting loop Connecting to DB Disconnecting from DB Ending script Disconnecting from DB Ending script Disconnecting from DB Ending script Disconnecting from DB Ending script Disconnecting from DB Ending script Check no. of fd's for ocius.msb using lsof -p 9940. Sleeping 30s