Hi All ,
Going thru some site I chanced upon this excercise and found it be somewhat challenging. Will really appreciate if some one has inputs for this program.
PRoblem:
Create a class for the purpose of monitoring data coming from a named
pipe under Linux. Assume a daemon somewhere has the pipe open and is
continuously writing information to it. The class will be used as a
part of a larger program to monitor output from this named pipe and log
it to a file, so it is necessary to implement this class using fork()
or Perl threads to prevent the remainder of the program from blocking.
The constructor should take the following arguments:
named_pipe - String containing full path to the pipe to be monitored
(e.g. "/tmp/mypipe"
, required
logfile - String containing full path to logfile to be written (e.g.
"/tmp/mypipe.output"
The constructor should not begin logging as in on() below, wait for the
user of the class to call those methods.
At least the following methods should exist:
on() - Start reading from the pipe and logging to the file. Append to
the file if it exists already. Return true if logging successfully
initiated.
off() - Stop reading from the pipe and logging to the file.
clean() - Unlink the log file.
dump() - Return an array of strings with the contents of the log file,
one line per string.
Going thru some site I chanced upon this excercise and found it be somewhat challenging. Will really appreciate if some one has inputs for this program.
PRoblem:
Create a class for the purpose of monitoring data coming from a named
pipe under Linux. Assume a daemon somewhere has the pipe open and is
continuously writing information to it. The class will be used as a
part of a larger program to monitor output from this named pipe and log
it to a file, so it is necessary to implement this class using fork()
or Perl threads to prevent the remainder of the program from blocking.
The constructor should take the following arguments:
named_pipe - String containing full path to the pipe to be monitored
(e.g. "/tmp/mypipe"
logfile - String containing full path to logfile to be written (e.g.
"/tmp/mypipe.output"
The constructor should not begin logging as in on() below, wait for the
user of the class to call those methods.
At least the following methods should exist:
on() - Start reading from the pipe and logging to the file. Append to
the file if it exists already. Return true if logging successfully
initiated.
off() - Stop reading from the pipe and logging to the file.
clean() - Unlink the log file.
dump() - Return an array of strings with the contents of the log file,
one line per string.