[lug] C(++) library to detect file type (a la 'file')

rm at fabula.de rm at fabula.de
Fri Nov 1 06:18:12 MST 2002


On Thu, Oct 31, 2002 at 10:53:18PM -0700, Tkil wrote:
> >>>>> "Scott" == Scott A Herod <herod at dimensional.com> writes:
> Scott> Yes, like the perl system call (you would probably want 'popen'
> Scott> which creates a return pipe for you).
> 
> You have to be pretty careful about the phrasing of that, to control
> how people parenthesize it when they read it.  On Unix derivatives,
> there is a very precise meaning of "system call": namely, something
> that invokes the kernel, and is typically described in section 2 of
> the man pages.

For a short moment i fancied exactely that: someone put a perl inter-
preter into the kernel :-))) (wasn't there once a freshmeat anounement
from someone who wanted to write an OS in Perl?)

> As you explain above, you were really talking about "system", the perl
> builtin function, which is really most similar to fork + exec + wait
> (all of which are system calls).

Hmmm, to be correct: all of those are libc functions that wrap arround
the corresponding system calls 'sys_fork, sys_execve, sys_wait4 etc.'

> If you want the output from a command in perl, you really want qx() or
> magic pipe opens.  Described in the "perlop" and "perlopentut" man
> pages, respectively.

Magic pipes for file magic, i like that :-)

 thx Ralf



More information about the LUG mailing list