Sometimes we need to start another program (process) in our own program to help us do some work, so how do we start other processes in our own process? There are a number of ways to do this in Linux, and here's a description of the differences
13.1: IntroductionDaemons also call the daemon process (daemon) A long-lived process. They often start when the system is bootstrap and terminate only when the system shuts down. Because they do not have control terminals, they are running in the
void init (void)169 {Pid,i int;171172 Setup (void *) &drive_info); Read hard disk parameters include partition table information and create virtual disk andInstall the root file system device. (kernel/blk_drv/hd.c,71)173 (void) Open ("/dev/tty0",
All say this theme is good, even I feel a little too big, but I think I still have to persist, efforts in a limited time to learn the secret of the Linux kernel, but also hope that we have more guidance, let me more progress. Today is all about the
The C language under Linux can use fork () to establish a child process.The fork function returns two values, and returns 0 for the child process; The parent process, which returns the child process ID. So withif (fork () ==0){The code snippet
1 Create two sub-processes using the fork function. Sends a message to the second child process in the first child process, and the second child process comes out and processes it.2 in the parent process, pipe communication is not applicable, so
Preface : When writing a multi-process program, we should understand how the operating system kernel does when creating a child process. When a new child process is created through the fork function, the kernel copies the contents of the user
First, get the ID#include #include pid_t getpid (void) Get this process IDpid_t getppid (void) Gets the parent process IDParent process: A new process is created in the existing process.Example: GETPID.C#include #include #include int main (){printf (
Original aircraftOriginal link: https://www.cnblogs.com/DOMLX/p/9612820.htmlUnder Linux:I. Service-side codeThe following closed file descriptor with multiple close, there may be some small partners have doubts .... I'll just say that when you
1. The process group leader cannot create a new session2. Session leader can reopen control terminal1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9Ten void My_daemon () {int PID, FD;1213//1. Transitioning to
Transferred from: http://www.cnblogs.com/xuxm2007/archive/2011/07/29/2121280.html #include int daemon (int nochdir,int noclose)When creating sprite processes, it is often necessary to modify the working directory of the sprite process to the "/"
Daemon processdaemons are long-lived processes that often start when the system is bootstrap and terminate only when the system shuts down. Because they do not have control terminals, they are running in the background. UNIX systems consist of a
The implementation of the server and the client chat with each other, no order restrictions, can be carried out at the same time.
Service side: SERVER.C
#include #include #include #include #include #include #include #include #include #include
The system () function is powerful, and many people use it with little knowledge of the Linux version of the system function first:
Copy Code code as follows:
#include
#include
#include
#include
int system (const char *
The following example invokes the LS command via execle;
The echo command was invoked through EXECLP;
#include
#include
#include "Ourhdr.h"
//
Char*env_init[] = {"User=unknown", "Path=/tmp", NULL};
Intmain ()
{
pid_t pid;
if ((PID = fork ())
{
Main (){pid_t pid;if (Pid=fork () {printf ("error!");}Else{if (pid==0)printf ("a/n");Elseprintf ("b/n");}}The result is to return a, B or b,aBecause the fork call will perform two returns from the child process and the parent process,
ConceptProgram: A file stored on disk that specifies the code to be executed and the action to be performed when it is run.Process: The process of loading a program into a piece of data in memory, the process of executing a program, producing,
The parent-child process is described earlier if multiple processes attempt to process the shared data. The final result depends on the order in which the process is run, and it is assumed that a competitive relationship has occurred. Take a look at
The concept of Guardian processThe daemon (Daemon) is generally designed to protect the normal operation of our programs/services, and start the program/recovery service again when the program is closed, abnormally exited, and so on.For example, the
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.