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.