In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1) create a child process, and the parent process exits
2) create a new session in the child process
The setsid () function is used to create a new session and act as the leader of the session group. Calling the setsid () function serves three purposes:
Let the process out of the control of the original session
Let the process get rid of the control of the original process group
Let the process get rid of the control of the original control terminal
3) change the working directory with the chdir () function
4) set the file permission mask with umask ()
5) close the file descriptor
# include # include int main (int argc, const char * argv []) {pid_t pid; int iJournal FD; char * buf = "This is a Daemon log\ n"; pid = fork (); if (pid
< 0) { perror("fail to fork\n"); exit(0); } if(pid >0) / / the parent process exits the first step {exit (0);} setsid (); / / the second step chdir ("/ tmp"); / / the third step umask (0); / / the fourth step for (I = 0 I < getdtablesize ()) / / the fifth step loops to delete the file descriptor {close (I) } while (1) {if ((fd = open ("daemon.log", O_CREAT | O_RDWR | Olympiad Appedition0667))
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.