Perl syscall Function



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.


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.


Following is the example code showing its basic usage −

#!/usr/bin/perl -w

$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 produces the following result −

PID of this process is 23705