UNIX Library

The routines in this section are specific to the UNIX version of ScriptEase. They are included internally to the ScriptEase program, and are available to any ScriptEase program executed by ScriptEase under UNIX.

Most of these routines allow the programmer to have more power than is generally acknowledged as safe under ScriptEase' guidelines. So be careful when you use these commands, they provide plenty of rope with which to hang yourself.


dlcall
 

DESCRIPTION

Call a routine in a shared object under Linux, Sun OS, Solaris, FreeBSD, or AIX (all Unix versions currently supported).

SYNTAX

int dlcall(string shared_object, string routine,...)

COMMENTS

dlcall() allows you to call routines in shared objects directly. The first parameter is the name of the shared object; the second is the name of the routine being called.

If a parameter is undefined when dlcall() is called, then it is assumed that parameter will be a 32-bit value that will be filled in (i.e., the address of a 32-bit data element is passed to the function, and that function will set the value).

If any parameter is a structure then it must be a structure that defines the binary data types in memory to represent the following variable. Before calling the DLL function, the structure will be copied to a binary buffer as described in BLObPut() and fwrite(). After calling the DLL function the binary data will be converted back into the data structure according to the rules defined in BLObGet() and fread(). Data conversion will be performed according to the current _BigEndianMode setting (see fread()).

RETURN

This function returns the result of the called function converted to integer form. If the given function does not exists, a run-time error is generated.


fork
 

DESCRIPTION

Create a duplicate of the current process.

SYNTAX

int fork()

COMMENTS

Two copies of the process now exist. Both pick up execution on return from the fork() call. See the return value below.

RETURN

The PID of the child is returned to the parent. A value of 0 is returned to the child.

SEE ALSO

waitpid


getcwd

DESCRIPTION

Get the current working directory.

SYNTAX

string getcwd(string buffer);

COMMENT

The full pathname of the current directory is copied to the given buffer.

RETURN

The function returns the value of its argument.


setsid
 

DESCRIPTION

Create a new session with no terminal.

SYNTAX

void setsid()

COMMENTS

This function allows your program to disattach itself from the terminal and continue to run. You call this, then fork(). If fork() returns non-zero, exit(0). The child will therefore continue to run, the parent closes leaving the terminal free.

EXAMPLE

setsid(); if( fork() ) exit(0);

SEE ALSO

fork()


setuid
 

DESCRIPTION

Change a process' user ID.

SYNTAX

int setuid(int uid)

COMMENTS

The user id of the running process is changed to the given id, if the user has priviledges to change to that id.

RETURN

0 is returned on success, -1 on failure.

SEE ALSO

getuid()


waitpid
 

DESCRIPTION

Wait for a child to exit and then clean it up.

SYNTAX

int waitpid(int pid,int status,int flags)

COMMENTS

See unix man page for information on this function. It is used most often to clean up child processes that you created with fork() to avoid zombie processes hanging around.

RETURN

The process id of the child that exited, -1 if error, 0 if WNOHANG is used and no child is available.

SEE ALSO

setuid()