Thread flock with pidHdl: FLOCK: Bareword "pidHdl" not allowed whi (5 answers)
Opened by Rufio at 2005-02-25 21:16

Rufio
 2005-02-25 21:16
#52153 #52153
User since
2003-12-22
7 Artikel
BenutzerIn
[default_avatar]
Hallo,

ich bringe dieses Script nicht zum Laufen. Es sollte überprüfen mit Hilfe einer *.pid Datei ob er bereits gestartet ist.
ohne use strict läuft es problemlos.
vielen Dank für Hilfe.

Rafael

Fehlermeldung:
Bareword "pidHdl" not allowed while "strict subs" in use at C:/xampp/cgi-bin/raumverwaltung_3.pl line 18. Bareword "pidHdl" not allowed while "strict subs" in use at C:/xampp/cgi-bin/raumverwaltung_3.pl line 22. Bareword "pidHdl" not allowed while "strict subs" in use at C:/xampp/cgi-bin/raumverwaltung_3.pl line 24.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl

use warnings;
use strict;
use Fcntl;
my $pidFile    = "C:/xampp/cgi-bin/raumverw_2.pid";

&CheckAllReadyRunning;

sub CheckAllReadyRunning {
#LOCK_SH = 1;
my $LOCK_EX = 2;
my $LOCK_NB = 4;
my $LOCK_UN = 8;

if( ! open( pidHdl, ">>$pidFile"))
{
   flock( pidHdl, $LOCK_UN);
   close( pidHdl);
   die;
}
if( ! flock( pidHdl, $LOCK_NB + $LOCK_EX))
{
   flock( pidHdl, $LOCK_UN);
   close( pidHdl);
   die;
}
truncate( pidHdl, 0);
select( pidHdl); $| = 1; select( STDOUT);
print( pidHdl "$$");
};


edit pq: code tags\n\n

<!--EDIT|pq|1109368535-->

View full thread flock with pidHdl: FLOCK: Bareword "pidHdl" not allowed whi