UNIX System Management: System calls-interprocess communication

Source: Internet
Author: User
Keywords Unix System Management inter-process communication
Tags calling calls communication function group process processes processing

Basically all system calls return 0 or positive numbers when they succeed, and negative values are returned when they fail.

Process user Flag Number Management

System call Format

#include <unistd.h>

unsigned short getuid ()

unsigned short getgid ()

unsigned short geteuid ()

unsigned short getegid ()

int setuid (int uid)

int setgid (int gid)

int seteuid (int euid)

int setegid (int egid)

Parameter and Function Description:

The first four system calls return the actual user flag number of the process, the valid user flag number, the actual user group flag number, and the valid group flag number. These calls always succeed. Setuid and Setgid are used to set the actual user (group) flag number and valid user (group) flag number for the process. If the active user flag number of the calling process is a Superuser flag number, the actual user (group) flag number and the valid user (group) flag number of the calling process are set to UID and GID, and if the calling process's valid user flag number is not a Superuser flag number, but his actual user (group) flag number is UID (GID), The valid user (group) flag number is set to UID or GID. If the calling process's valid user flag number is not a Superuser flag number, and his actual user (group) flag number is not a UID (GID), the call fails. Seteuid and Setegid are similar to Setuid,setgid, but only work with valid user (group) flag numbers.

Process Flag Number Management

System call Format

#include <sys/types.h>

#include <unistd.h>

int Getpid ()

int Getpgrp ()

int Getppid ()

int Setpgrp ()

int Setsid ()

Parameter and Function Description:

The first three system calls return process flag numbers, process group flag numbers, and their parent process flag numbers, respectively. They always return successfully. Four, five calls set the process group flag number, and he changes the process group flag number of the calling process to the process flag number of the calling process, making it the process group's first process and returning the new process group flag number.

Signal mechanism

Signal system call Format

#include <signal.h>

void (*signal (Sig,func)) ()

int sig; /* Signal Value * *

void (*func) (); /* Signal Processing mode * *

Parameter and Function Description:

Sets how the calling process handles the signal sig, as defined by the function func. When execution succeeds, returns the previous value of the calling process for signal sig processing, which returns 1 when it fails. The value of the parameter func is the sig_dfl,sig_ign or the user signal processing function address, respectively, representing the default, or the way and the capture.

The value of the sig is (important list)

Sighup hangs. When the terminal is suspended, the signal is sent to all processes associated with the terminal. When the first process in a process group interrupts for some reason, it also sends the signal to each process in the group

SIGINT interrupted. When the interrupt key is tapped, the signal is sent to all processes associated with the terminal

Sigquit exit. The signal is sent to all processes associated with the terminal when the (ctrl+\) key is tapped

SIGKILL killed. Kill the signal of the process, he can't be ignore

Contravention of SIGSEGV section

Sigpipe write pipe wrong. When a process writes data to a pipeline that does not have any read processes, the signal is sent

SIGALRM Alarm Clock.

Sigterm Software termination Signal

SIGUSR1 Custom Signal

SIGUSR2 Custom Signal

The SIGCLD process dies. When a child process dies for some reason, it sends the signal to the parent process.

Sigurg Emergency Socket Interface condition

Sigpoll a user-specified event occurs on a stream, the flow control mechanism sends the signal to the user process

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.