#!/usr/bin/perl -w
use Fcntl;
# Experimenting with fcntl system call
## open this file
open( FH, ">>fcntl.pl" );
$cur_opts = fcntl( FH, &F_GETFL, 0 );
# The print statement of death....
# print "cur_opts -> $cur_opts\n";
$rc = fcntl( FH, &F_SETFL, $cur_opts );
# "fixes" The print statement of death...
#$rc = fcntl( FH, &F_SETFL, $cur_opts & 0xffffffff );
print "rc -> $rc\n";
$new_opts = fcntl( FH, &F_GETFL, 0 );
print "new_opts -> $new_opts\n";
if ( $new_opts != $cur_opts ) {
print "ERROR\n";
} else {
print "Calling F_SETFL with F_GETGL return value succeeded.\n";
}
print "new_opts -> $new_opts cur_opts -> $cur_opts\n";
####
rc -> 0 but true
new_opts -> 1025
Calling F_SETFL with F_GETGL return value succeeded.
new_opts -> 1025 cur_opts -> 1025
####
cur_opts -> 1025
rc -> 0 but true
new_opts -> 8193
ERROR
new_opts -> 8193 cur_opts -> 1025V@S@ÿÿÿÿ0ÿÿÿÿÿÿÿÿHÿÿÿÿ N@