D
Dean Karres
Hi,
Tested on RedHat and Ubuntu
I am trying to create a daemon the tails and parses a "binary" (fixed
length record) log-file. I have tried using Proc:aemon and rolling
my own daemonization code and I really don't think that is the issue
though. My problem is when I try to create a run-lock pid file in /
var/run.
the basic flow is:
- start syslog
- become a daemon
- try to create/open & flock a pid file
- ... everything else
I know syslog is working even after the forks. I know the forks are
working. I know the pid file is being initially created but flock
bombs and tells me "Inappropriate ioctl for device".
the pid file open code is:
sysopen($PIDFILE, $PIDFILEPATH, O_CREAT | O_WRONLY) ||
die "Can not open pid file: $PIDFILEPATH\n";
if (flock($PIDFILE, LOCK_EX | LOCK_NB) != 0) {
die "Can not lock pid file: $PIDFILEPATH: $!: $?\n";
}
truncate($PIDFILE, 0) ||
die "Can not truncate pid file: $PIDFILEPATH\n";
print $PIDFILE "$$\n";
The "$PIDFILEPATH" is /var/run/filename.pid
ideas?
Tested on RedHat and Ubuntu
I am trying to create a daemon the tails and parses a "binary" (fixed
length record) log-file. I have tried using Proc:aemon and rolling
my own daemonization code and I really don't think that is the issue
though. My problem is when I try to create a run-lock pid file in /
var/run.
the basic flow is:
- start syslog
- become a daemon
- try to create/open & flock a pid file
- ... everything else
I know syslog is working even after the forks. I know the forks are
working. I know the pid file is being initially created but flock
bombs and tells me "Inappropriate ioctl for device".
the pid file open code is:
sysopen($PIDFILE, $PIDFILEPATH, O_CREAT | O_WRONLY) ||
die "Can not open pid file: $PIDFILEPATH\n";
if (flock($PIDFILE, LOCK_EX | LOCK_NB) != 0) {
die "Can not lock pid file: $PIDFILEPATH: $!: $?\n";
}
truncate($PIDFILE, 0) ||
die "Can not truncate pid file: $PIDFILEPATH\n";
print $PIDFILE "$$\n";
The "$PIDFILEPATH" is /var/run/filename.pid
ideas?