当前位置: 首页 > 文档资料 > Perl 入门教程 >

syscall

优质
小牛编辑
115浏览
2023-12-01

描述 (Description)

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

语法 (Syntax)

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

syscall EXPR, LIST

返回值 (Return Value)

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

例子 (Example)

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

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