Skip to content

Latest commit

 

History

History
83 lines (48 loc) · 1.92 KB

syscall.pod

File metadata and controls

83 lines (48 loc) · 1.92 KB

NAME

syscall - send system calls from your shell

SYNOPSIS

syscall [-<n>] name [args...] [, name [args...]]...

syscall [-h|--help]

syscall [-v|--version]

To replicate the following C fragment:

int fd = open("/my/file", O_WRONLY, 0755);
write(fd, "hello", strlen("hello"));
close(fd);

you would use syscall like this:

syscall open /my/file 1 0755 , write \$0 hello \#hello , close \$0

To print the return code of a system call, use echo:

syscall open /dev/random 0 , echo \$0

DESCRIPTION

Execute a list of raw system calls. All the system calls listed in your system's unistd.h are supported, with up to 5 arguments. A maximum of 20 calls can be executed per invocation, each separated by a comma.

Arguments starting by a # symbol are used to give a string length. For instance, #hello would be evaluated as 5.

Arguments starting by a $ followed by a number from 0 to 19 refer to a previous system call return code. For instance, $0 refers to to the return code of the first system call executed. To display those values, use the echo built-in command.

The echo command can be used like any other system call to easily display $ or # values, or any string or number.

OPTIONS

-<n>
# print "foo" 10 times
syscall -10 write 1 "foo\n" 4

Execute the given commands n times, where n is an integer between 0 and INT_MAX.

-h --help
-v --version

EXIT STATUS

0 if all syscalls were successful, 1 on error.

Note that if any system returns -1, the program will exit immediately after printing the associated error message.

COPYRIGHT

Copyright 2017 Olivier Duclos.

This program is distributed under the ISC license.

Heavily inspired by the syscall command from AIX.

SEE ALSO

Linux Programmer's manual : syscall(2)

This project's homepage: https://github.com/oliwer/syscall