Flowdock
syscall(*args) public

Calls the operating system function identified by num and returns the result of the function or raises SystemCallError if it failed.

Arguments for the function can follow num. They must be either String objects or Integer objects. A String object is passed as a pointer to the byte sequence. An Integer object is passed as an integer whose bit size is same as a pointer. Up to nine parameters may be passed.

The function identified by num is system dependent. On some Unix systems, the numbers may be obtained from a header file called syscall.h.

syscall 4, 1, "hello\n", 6   # '4' is write(2) on our box

produces:

hello

Calling syscall on a platform which does not have any way to an arbitrary system function just fails with NotImplementedError.

Note: syscall is essentially unsafe and unportable. Feel free to shoot your foot. The DL (Fiddle) library is preferred for safer and a bit more portable programming.

Show source
Register or log in to add new notes.