flock() fails under Solaris
| From: | Andreas Jung | Date: | Tue, 28 Mar 2000 06:53:37 +0000 |
| Subject: | flock() fails under Solaris | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12719@lists.php.net to get a copy of this message | ||
Take a look at the following code:
function log_system_output($cmd,$outp,$st,$ts,$te) {
global $LOG_DIR;
$fp = fopen("$LOG_DIR/output.log","a");
flock($fd,2);
fwrite($fp,"--------------------------------------------------------------------------------\n");
fwrite($fp,"Kommando: $cmd\n");
fwrite($fp,sprintf("Gestartet: %s Terminiert: %s Gesamtlaufzeit: %-.3lf\n",
strftime("%Y-%m-%d %H:%M:%S",$ts),strftime("%Y-%m-%d
%H:%M:%S",$te),$te-$ts));
fwrite($fp,"Exitcode: $st\n");
fwrite($fp,"Ausgabe: \n$outp\n");
// flock($fd,3);
fclose($fp);
}
The execution of the function fails with the message:
Warning: Supplied argument is not a valid File-Handle resource in ...
When I remove the flock() call the function works as expected.
Environ: Solaris 2.7,gcc-2.95-2,PHP4RC1
Andreas Jung
--
_\\|//_
(' O-O ')
------------------------------ooO-(_)-Ooo--------------------------------------
Andreas Jung, Saarbrücker Zeitung Verlag und Druckerei GmbH
Saarbrücker Daten-Innovations-Center
Untertürkheimerstraße 15, D-66103 Saarbrücken, Germany
Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509
Email: ajung@sz-sb.de (PGP key available)
-------------------------------------------------------------------------------