int getpid(void)
int getppid(void)
getpgid(pid_t pid)
int setpgid(pid_t pid, pid_t pgid)
Sets the process group ID of the process with ID pid to pgid.
If pid is equal to 0, the process ID of the calling process
is used.
int getuid(void)
which gets the UID of the process, and
int geteuid(void)
which gets the EUID of the process.
int getgid(void)
which gets the GID of the process and
int getegid()
which gets the EGID of the process.
int setuid(int uid)
which sets the UID and EUID, and
int setgid(int gid)
which sets the GID and EGID.
Both calls return 0 on success, or -1 on error.
HOME=/usr/spg/geoff
TERM=/tvi950
PATH=/usr/bin:/usr/spg/geoff/bin
extern char *environ[];
A NULL pointer signifies the last such string.
int main(int argc,char *argv[],char *env[])
char *getenv(char keyword[]);
getenv returns a pointer to the string value, or
NULL if no value is specified.
int setenv(char *name,char *value,int overwrite);
unsetenv(char *name);
searches the directories in the PATH environment variable
for the program.
provides the arguments as an array of pointers, in
the same way as they are received by main.
The last pointer must be NULL.
combines the advantages of execlp and execv
The environment is an array of pointers to strings that
describe the environment to be passed to the new program.
This is the true exec, the others end up calling
this one.
int wait(int *status_pointer);
If which is PRIO_PROCESS then who is
the PID, or 0 for the current process.
If which is PRIO_USER then who is the
real user ID for the processes.
If which is PRIO_PGRP then who is the
process group ID.
prio is the new priority value.
struct rlimit is defined as:
struct rlimit {
rlim_t rlim_cur; //----Soft limit
rlim_t rlim_max; //----Hard limit
};
If the process exceeds a soft limit it may be sent a signal:
A process cannot exceed its hardlimit.
struct rusage {
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
long ru_maxrss; /* maximum resident set size */
long ru_ixrss; /* integral shared memory size */
long ru_idrss; /* integral unshared data size */
long ru_isrss; /* integral unshared stack size */
long ru_minflt; /* page reclaims */
long ru_majflt; /* page faults */
long ru_nswap; /* swaps */
long ru_inblock; /* block input operations */
long ru_oublock; /* block output operations */
long ru_msgsnd; /* messages sent */
long ru_msgrcv; /* messages received */
long ru_nsignals; /* signals received */
long ru_nvcsw; /* voluntary context switches */
long ru_nivcsw; /* involuntary context switches */
};
and a struct timeval is defined as:
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
This is a function that returns a pointer to a function
that receives an int.
The second argument is the same.
void pause(void);
causes the calling process to suspend until a non-ignored
signal is received.
signum specifies which signal to handle,
*act specifies what to do,
*oldact, if not NULL, saves the old action.
A struct sigaction contains:
date ls -l cat fred.cNotes:
if (fork() == 0) { printf("Here comes the directory listing\n"); execlp("/bin/ls","ls",NULL); printf("That is the end of the listing\n"); } else { ... /*----Some legal stuff here */ }