Perl Programming/Keywords/syscall

Previous: symlink Keywords Next: sysopen

The syscall keywordEdit

syscall makes a system call with the first element of the list that may have upto 14 parametres. The remaining parametres are passed altogether as arguments to the system call. If the command is unimplemented, syscall raises an exception.

All given arguments that are numeric are passed as an int. If they are not, a pointer to the string value is passed. A string literal (or other read-only strings) are not allowed as an argument, as Perl has to assume that any string pointer might be written through. If the integer arguments are not literals and have never been interpreted in a numeric context, it may be necessary to add a 0 to them to force them to look like numbers.

syscall emulates the syswrite function (or vice versa)

syscall returns whatever value returned by the called system call. On failure, -1 is returned and $! (errno) is set. As some system calls can legitimately return -1, 0 should be assigned to $! before the call.

syscall(&SYS_pipe) returns the file number of the read end of the pipe it creates, but there is no way to retrieve the file number of the other end. This is a problem that can be avoided by using pipe instead.


  syscall NUMBER, LIST


require '';        # You may need to run h2ph

$s = "Helloǃ\n";

syscall(&SYS_write, fileno(STDOUT), $s, length $s)

See alsoEdit

syscall sysopen sysread sysseek system syswrite
Previous: symlink Keywords Next: sysopen