当前位置:网站首页>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
边栏推荐
- 新手怎么选择投资理财产品的等级?
- canvas管道动画js特效
- NVIDIA's CVPR 2022 oral is on fire! 2D images become realistic 3D objects in seconds! Here comes the virtual jazz band!
- 请问有国内靠谱低手续费的期货开户渠道吗?网上开户安全吗?
- Grpc local test joint debugging tool bloomrpc
- JS proxy mode
- 使用Live Chat促进业务销售的惊人技巧
- LeetCode: 137. Number II that appears only once
- Get the QR code of wechat applet with parameters - and share the source code of modifying the QR code logo
- [Eureka registry]
猜你喜欢
随机推荐
PHP encapsulates a file upload class (supports single file and multiple file uploads)
How does home office manage the data center network infrastructure?
Phpstrom code formatting settings
vim的使用
队列Queue
CICFlowMeter源码分析以及为满足需求而进行的修改
Literature Research Report
字节跳动-面试官: 谈下音视频同步原理,音频和视频能绝对同步吗?
Internet of things? Come and see Arduino on the cloud
js代理模式
416 binary tree (first, middle and last order traversal iteration method)
411-栈和队列(20. 有效的括号、1047. 删除字符串中的所有相邻重复项、150. 逆波兰表达式求值、239. 滑动窗口最大值、347. 前 K 个高频元素)
十大证券公司哪个佣金最低,最安全可靠?有知道的吗
PostgreSQL DBA快速入门-通过源码编译安装
416-二叉树(前中后序遍历—迭代法)
413-二叉树基础
分布式 | 如何与 DBLE 进行“秘密通话”
In depth study paper reading target detection (VII) Chinese English Bilingual Edition: yolov4 optimal speed and accuracy of object detection
LeetCode: 137. Number II that appears only once
indexedDB本地存储,首页优化









