当前位置:网站首页>Engine localization adaptation & Reconstruction notes
Engine localization adaptation & Reconstruction notes
2022-06-24 10:05:00 【51CTO】
About daemons dup stderr problem ;
fd = open("/dev/null", O_RDWR);
if (dup2(fd, STDIN_FILENO) == -1)
if (dup2(fd, STDOUT_FILENO) == -1)
#if xxx
if (dup2(fd, STDERR_FILENO) == -1)
#else
fd_log = open("pathlog", O_RDWR);
if (dup2(fd_log, STDERR_FILENO) == -1)
#endif
if (fd > STDERR_FILENO) {
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
take dup2(fd_log, stderr) still dup2(fd_null, stderr);
That is, the standard error is redirected to Black hole or log In file
look down man dup Result :dup2() makes newfd be the copy of oldfd, closing newfd first if necessary,
NAME
dup, dup2, dup3 - duplicate a file descriptor
SYNOPSIS
#include <unistd.h>
int dup(int oldfd);
int dup2(int oldfd, int newfd);
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <fcntl.h> /* Obtain O_* constant definitions */
#include <unistd.h>
int dup3(int oldfd, int newfd, int flags);
DESCRIPTION
These system calls create a copy of the file descriptor oldfd.
dup() uses the lowest-numbered unused descriptor for the new descriptor.
dup2() makes newfd be the copy of oldfd, closing newfd first if necessary, but note the following:
* If oldfd is not a valid file descriptor, then the call fails, and newfd is not closed.
* If oldfd is a valid file descriptor, and newfd has the same value as oldfd, then dup2() does nothing, and returns newfd.
After a successful return from one of these system calls, the old and new file descriptors may be used interchangeably. They refer to the same open file description (see open(2)) and thus share file offset and file status flags; for
example, if the file offset is modified by using lseek(2) on one of the descriptors, the offset is also changed for the other.
The two descriptors do not share file descriptor flags (the close-on-exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the duplicate descriptor is off.
dup3() is the same as dup2(), except that:
* The caller can force the close-on-exec flag to be set for the new file descriptor by specifying O_CLOEXEC in flags. See the description of the same flag in open(2) for reasons why this may be useful.
* If oldfd equals newfd, then dup3() fails with the error EINVAL.
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
Engine precautions :
- Process name
- cpu binding
- Process resource settings (file_limit core_limit signal_mask)
- Time stamp setting ( Multi process / Multithreading )volatile Prevent optimization
- Daemon
- signal processing as well as coredump Handle
- log Set up
- Processing parameters
- Process unique instance
- Get rid of root Privilege
- Interprocess communication -socketpair pipe unix-socket Shared memory (mmap munmap as well as shmget shmat shmctl) Shared memory blog pipe-unix blog
Network middleware :
use libevent libuv Re encapsulation or Write again in combination with your own business ?
Protocol analysis :
Packing problem :
- fakeroot jurisdiction : Use fakeroot simulation root Authority executor , When packing , The owner of the file in the package must be root. Must be root Permission to execute packaged commands , But you should avoid using... When making packages root jurisdiction . To solve this contradiction ,fakeroot It was developed . stay fakeroot Environment , Working with files is like using root Same as the operation file , however , In fact, the file permissions in the system are the same as the original permissions .
LD_PRELOAD=//usr/userpath/x86build/lib/libfakeroot.so python build_packet.py
http proxy server (3-4-7 Layer of the agent )- Network event library common component 、 kernel kernel drive Camera drive tcpip Network protocol stack 、netfilter、bridge Seems to have seen !!!! But he that doeth good Don't ask future -- Height and weight 180 Fat man
边栏推荐
- port 22: Connection refused
- 桌面软件开发框架大赏
- Idea cannot save settings source root d:xxxx is duplicated in module XXX
- Five heart matchmaker
- [input method] so far, there are so many Chinese character input methods!
- NVIDIA's CVPR 2022 oral is on fire! 2D images become realistic 3D objects in seconds! Here comes the virtual jazz band!
- 居家办公如何管理数据中心网络基础设施?
- Regular matching mailbox
- Observer mode
- 队列Queue
猜你喜欢
随机推荐
涂鸦智能携多款重磅智能照明解决方案,亮相2022美国国际照明展
Use of vim
Getting user information for applet learning (getuserprofile and getUserInfo)
Arbre binaire partie 1
植物生长h5动画js特效
SQL-统计连续N天登陆的用户
Recursive traversal of 414 binary tree
JCIM|药物发现中基于AI的蛋白质结构预测:影响和挑战
How do novices choose the grade of investment and financial products?
针对《VPP实现策略路由》的修正
顶刊TPAMI 2022!基于不同数据模态的行为识别:最新综述
如何提高网络基础设施排障效率,告别数据断档?
引擎国产化适配&重构笔记
Producer / consumer model
PHP encapsulates a file upload class (supports single file and multiple file uploads)
Open Oracle server under Linux to allow remote connection
Queue queue
GIS实战应用案例100篇(十四)-ArcGIS属性连接和使用Excel的问题
How to solve multi-channel customer communication problems in independent stations? This cross-border e-commerce plug-in must be known!
编程题(持续更新)








