Perl syscall 函数



描述

此函数调用指定为列表第一个元素的系统调用,并将剩余元素作为参数传递给系统调用。如果给定参数是数字,则该参数将作为 int 传递。如果不是,则传递对字符串值的指针。

语法

以下是此函数的简单语法 -

syscall EXPR, LIST

返回值

此函数在系统调用失败时返回 -1,并在成功时返回系统函数返回的值。

示例

以下是显示基本用法的示例代码 -

#!/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 );

执行上述代码时,它将产生以下结果 -

PID of this process is 23705
perl_function_references.htm
广告
© . All rights reserved.