Perl syscall Function

Advertisements


Description

This function calls the system call specified as the first element of the list, passing the remaining elements as arguments to the system call. If a given argument is numeric, the argument is passed as an int. If not, the pointer to the string value is passed.

Syntax

Following is the simple syntax for this function:

syscall EXPR, LIST

Return Value

This function returns -1 on failure of system call and values returned by system function on success.

Example

Following is the example code showing its basic usage:

#!/usr/bin/perl -w

require("syscall.ph");
$pid = syscall(&SYS_getpid);

print "PID of this process is $pid\n";

# To create directory use the following
$string = "newdir";
syscall( &SYS_mkdir, $string );

When above code is executed, it produced following result

PID of this process is 23705


Advertisements
Advertisements