473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

perl fork( ) doubt

89
I tried a small example in perl forking.
I opena connection with sql database in the parent or main program as follws:

Expand|Select|Wrap|Line Numbers
  1. $dbh = DBI->connect("DBI:mysql:database=$database;host=$host", $user, $pass) || die "\nDB connection error!\n";
And I try to execute some mql commands and it works fine.

As one of the process will take more time to finish, I open a fork as follows. And I try to do some sql commands inside the child process as below:

Expand|Select|Wrap|Line Numbers
  1.  $pid = fork();
  2. if( $pid == 0 ){
  3. $sth = $dbh->prepare("update $table SET STATUS=0 where CONFIGID=$id");
  4.  $sth->execute(); 
  5. }
But I get an error message as below:
Expand|Select|Wrap|Line Numbers
  1. DBD::mysql::st execute failed: MySQL server has gone away at test.pl line 172.
Do I have to open the database connection again inside the child process? I also tried using
Expand|Select|Wrap|Line Numbers
  1. $dbh->{'mysql_auto_reconnect'} = 1;
but I get the same error. Please let me know.

Thanks and Regards
Jul 23 '08 #1
0 1710

Sign in to post your reply or Sign up for a free account.

Similar topics

31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
1
by: sm00thcrimnl13 | last post by:
if i have windows 2000 and know how to write perl scripts, how to i actuvate the script through perl?
1
by: Babu | last post by:
Hi, I am a Perl newbie and have a doubt on Perl exception handling. My understanding regarding exception handling is execute a piece of code, if any exception occurs, handle the exception and...
82
by: Edward Elliott | last post by:
This is just anecdotal, but I still find it interesting. Take it for what it's worth. I'm interested in hearing others' perspectives, just please don't turn this into a pissing contest. I'm in...
21
by: anshul1806 | last post by:
hi all , I am wondering why a call to fork fails to print some statements in the child. It works fine when terminal is defualt for O/p . in case i try redirection it fails to redirect...
2
by: sandhya2006 | last post by:
Hii, I hav a doubt in perl,Assume there is many html files in a folder I have to Take all files and display it into text file without displaying the tags.Please reply atleast for displaying...
2
by: sandhya2006 | last post by:
Hi friends Iam new to perl Can anyone help me. How to print many html files into one text file using perl,now i can able to print one html file into one text file.
3
by: bp4444 | last post by:
On a HPUX, a CPP program. In main() defined a variable as int x = 900, called fork(), changed value of x as 89 in child process. Printed the address of x and value of x in child process and also...
6
by: raj123brothers | last post by:
any one help me to get a owner name in perl
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.