[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [SpeechIO-14] mknod vs. mkfifo



> /dev/speech is created with:
> 
>   if( system('mknod',$fifo,'p') && system('mkfifo',$path) ) {
>     die "error creating '$fifo' $!\n";
>   }
> 
> should this be
> 
>   if( !system('mknod',$fifo,'p') && !system('mkfifo',$fifo) ) {
>     die "error creating '$fifo' $!\n";
>   }

After reading about the freebsd user's comments, I lookd, and Linux 
(at least RH5.0 does) have a mkfifo command, and I was able to create
a fifo with a single command.  

Secondly, your comments look correct, system() as documented in 'man perlfunc'
says that it returns the exit code of the program being run, so it should
be an inverted logical test (as in the second example above), though the
documentation goes on to say that you have to divide (by this they mean do a 
right shift fo 8 bits, which is actually equivalent to dividing by 256 when
you're talking about binary, but not when you're talking about the mathmatics 
[i.e. solving this "x / 256 = 0" for x doesn't give you the same result set as
'x >> 8') the exit code by 256 to get actual exit code.

So, we should probably be doing this (one way of writing it):

  unless( (system('mkfifo',$fifo)>>8) ) {
    die "error creating '$fifo' $!\n";
  }

This is how I understand things should be done according to the perlfunc 
documentation.


k

------------------------------------------------------------------------------
"Perl combines all of the worst aspects of BASIC, C and line noise." 
    -- Keith Packard <keithp@ncd.com>
mortis@voicenet.com                            http://www.voicenet.com/~mortis
------------------------------------------------------------------------------