当前位置:网站首页>引擎国产化适配&重构笔记
引擎国产化适配&重构笔记
2022-06-24 09:36:00 【51CTO】
关于守护进程dup stderr问题;
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.
将dup2(fd_log, stderr)还是dup2(fd_null, stderr);
也就是标准错误重定向到 黑洞还是 log文件中
看下man dup的结果: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.
引擎注意事项:
- 进程名称
- cpu绑定
- 进程资源设置(file_limit core_limit signal_mask)
- 时间戳的设置 (多进程/多线程 )volatile 防止优化
- 守护进程
- 信号处理 以及 coredump处理
- log设置
- 参数处理
- 进程唯一实例
- 去掉root 特权
- 进程间通信-socketpair pipe unix-socket 共享内存(mmap munmap以及shmget shmat shmctl) 共享内存blog pipe-unix blog
网络中间件 :
采用 libevent libuv 再次封装还是 结合自己业务再次编写?
协议解析:
打包问题:
- fakeroot权限:使用fakeroot模拟root权限执行程序,在打包的时候,包里面的文件所有者必须是root。必须以root 权限来执行打包命令,但是应该避免在制作包的时候使用root权限。 为了解决这个矛盾,fakeroot被开发出来了。在fakeroot环境中,操作文件就像使用root操作文件一样,但是,实际上系统中文件的权限还是原来的权限。
LD_PRELOAD=//usr/userpath/x86build/lib/libfakeroot.so python build_packet.py
http代理服务器(3-4-7层代理)-网络事件库公共组件、内核kernel驱动 摄像头驱动 tcpip网络协议栈、netfilter、bridge 好像看过!!!! 但行好事 莫问前程 --身高体重180的胖子
边栏推荐
- Ggplot2 color setting summary
- Summary of medical image open source datasets (II)
- Literature Research Report
- Oracle viewing data file header SCN information
- 5分钟,客服聊天处理技巧,炉火纯青
- Oracle查看数据文件头SCN信息
- Desktop software development framework reward
- CICFlowMeter源码分析以及为满足需求而进行的修改
- [custom endpoint and implementation principle]
- IDEA 无法保存设置 源根 D:XXXX在模块XXX中重复
猜你喜欢
随机推荐
蜜罐2款hfish,ehoney
Reasons for the failure of digital transformation and the way to success
ggplot2颜色设置总结
How to solve multi-channel customer communication problems in independent stations? This cross-border e-commerce plug-in must be known!
二叉树第一部分
使用Live Chat促進業務銷售的驚人技巧
Five heart matchmaker
How to standardize data center infrastructure management process
Threejs MMD model loading + contour loading + animation loading + Audio loading + camera animation loading +ammojs loading gltf model loading +gltf reflection adjustment
Wechat applet learning to achieve list rendering and conditional rendering
Operator details
414-二叉树的递归遍历
100 GIS practical application cases (XIV) -arcgis attribute connection and using Excel
Endgame P.O.O
5分钟,客服聊天处理技巧,炉火纯青
LeetCode: 137. Number II that appears only once
ssh远程免密登录
桌面软件开发框架大赏
grpc本地测试联调工具BloomRPC
使用Live Chat促进业务销售的惊人技巧









