PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at mbay dot net>
Subject: Sybperl and fork()
Date: Aug 19 1998 9:45PM

Wechsler, Steven M writes:
 > I believe this was covered before, but what happens to a DBLibrary
 > connection after a fork()?  My gut feeling is to close the connection in
 > the child proc immediately after the fork, and open a new one, and to
 > leave the process in the parent process alone.

If you close the connection in the child, the same connection will
normally be closed in the parent as well (at least if dbclose() is
called).

Sybperl does NOT close the Sybase side of connections on open
connections that are inheritted over a fork, so you should be able to
close (ie destroy or undefine) the handle that you inherit and open a
new one.

Code like this shoudl also be fine:

$dbh = new Sybase::DBlib ...

if(!fork()) {
	# in child
	$dbh = new Sybase::DBlib ...

	etc...
} else {
	# parent...
}

This basically opens a new connection in the child, and "hides" the
old (parent) connection. 

Michael
-- 
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@mbay.net       -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com