fork

Prevent file descriptors inheritance during Linux fork

孤者浪人 提交于 2019-12-17 09:41:38
问题 How do you prevent a file descriptor from being copy-inherited across fork() syscalls (without closing it, of course) ? I am looking for a way to mark a single file descriptor as NOT to be (copy-)inherited by children at fork(), something like a FD_CLOEXEC-like hack but for forks (so a FD_DONTINHERIT feature if you like). Anybody did this? Or looked into this and has a hint for me to start with? Thank you UPDATE: I could use libc's __register_atfork __register_atfork(NULL, NULL, fdcleaner,

github如何精确搜索项目

那年仲夏 提交于 2019-12-17 09:05:55
1.常用词含义 watch:会持续收到项目的动态 fork:复制某个项目到自己的仓库 star:可以理解为点赞 clone:将项目下载到本地 follow:关注你感兴趣的作者,会收到他们的动态 2.in关键词限制搜索范围 (1)公式 xxx in:name 项目名包含xxx的 xxx in:description 项目描述包含xxx的 xxx in:readme 项目 (2)case 搜索项目名或者readme中包含秒杀的项目 seckill in:name,readme 3.stars或fork数量关键词去查找 (1)公式 :> 或者 :>= 数字1..数字2 (2)case 查找star数大于等于5000的springboot项目 springboot stars:>=5000 查找fork数大于500的springcloud项目 springcloud forks:>500 查找fork在100到200之间并且stars数在80到100之间的springboot项目 springboot forks:100..200 stars:80..100 4.awesome加强搜索 (1)公式 awesome 关键字 awesome 系列一般是用来收集学习、工具、书籍类相关的项目 (2)case 搜索优秀的redis相关的项目,包括框架、教程等 awesome redis 5

Having trouble with fork(), pipe(), dup2() and exec() in C

老子叫甜甜 提交于 2019-12-17 08:54:15
问题 Here's my code: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <wait.h> #include <readline/readline.h> #define NUMPIPES 2 int main(int argc, char *argv[]) { char *bBuffer, *sPtr, *aPtr = NULL, *pipeComms[NUMPIPES], *cmdArgs[10]; int fdPipe[2], pCount, aCount, i, status, lPids[NUMPIPES]; pid_t pid; pipe(fdPipe); while(1) { bBuffer = readline("Shell> "); if(!strcasecmp(bBuffer, "exit")) { return 0; } sPtr = bBuffer; pCount = -1; do { aPtr = strsep(&sPtr, "|"); pipeComms[+

Why fork() twice [duplicate]

好久不见. 提交于 2019-12-17 08:52:34
问题 This question already has answers here : What is the reason for performing a double fork when creating a daemon? (9 answers) Closed 4 years ago . Nagios lets me configure child_processes_fork_twice=<0/1> . The documentation says This option determines whether or not Nagios will fork() child processes twice when it executes host and service checks. By default, Nagios fork()s twice. However, if the use_large_installation_tweaks option is enabled, it will only fork() once. As far as I know fork(

Run a ffmpeg process in the background

廉价感情. 提交于 2019-12-17 07:27:56
问题 I am wanting to use ffmpeg to convert video to .flv in php. Currently I have this working, but it hangs the browser until the file is uploaded and is finished. I have been looking at the php docs on how to run an exec() process in the background, while updating the process using the returned PID. Here is what I found: //Run linux command in background and return the PID created by the OS function run_in_background($Command, $Priority = 0) { if($Priority) $PID = shell_exec("nohup nice -n

Are file descriptors shared when fork()ing?

我与影子孤独终老i 提交于 2019-12-17 06:14:22
问题 Let's say I open a file with open() . Then I fork() my program. Will father and child now share the same offset for the file descriptor? I mean if I do a write in my father, the offset will be changed in child too? Or will the offsets be independent after the fork() ? 回答1: From fork(2) : * The child inherits copies of the parent’s set of open file descrip- tors. Each file descriptor in the child refers to the same open file description (see open(2)) as the corresponding file descriptor in the

Are file descriptors shared when fork()ing?

痞子三分冷 提交于 2019-12-17 06:14:19
问题 Let's say I open a file with open() . Then I fork() my program. Will father and child now share the same offset for the file descriptor? I mean if I do a write in my father, the offset will be changed in child too? Or will the offsets be independent after the fork() ? 回答1: From fork(2) : * The child inherits copies of the parent’s set of open file descrip- tors. Each file descriptor in the child refers to the same open file description (see open(2)) as the corresponding file descriptor in the

Portable way to pass file descriptor between different processes

人走茶凉 提交于 2019-12-17 03:09:32
问题 On most UNIX systems passing an open file between processes can be easily done for child/parent processes by fork(); however I need to share a fd "after" the child was already forked. I've found some webpages telling me that sendmsg() may work for arbitary processes; but that seems very OS dependent and complex. The portlisten seems like the best example I can find, but I'd prefer a good wrapper library like libevent that hides all the magic of kqueue, pool, .... Does anyone know if there's

Continue PHP execution after sending HTTP response

二次信任 提交于 2019-12-17 01:44:04
问题 How can I have PHP 5.2 (running as apache mod_php) send a complete HTTP response to the client, and then keep executing operations for one more minute? The long story: I have a PHP script that has to execute a few long database requests and send e-mail, which takes 45 to 60 seconds to run. This script is called by an application that I have no control over. I need the application to report any error messages received from the PHP script (mostly invalid parameter errors). The application has a

进程控制实验--fork()

三世轮回 提交于 2019-12-16 22:51:20
二 进程的控制 实验目的 1、掌握进程另外的创建方法 2、熟悉进程的睡眠、同步、撤消等进程控制方法 实验内容 1、用fork( )创建一个进程,再调用exec( )用新的程序替换该子进程的内容 2、利用wait( )来控制进程执行顺序 实验指导 一、所涉及的系统调用 在UNIX/LINUX中fork( )是一个非常有用的系统调用,但在UNIX/LINUX中建立进程除了fork( )之外,也可用与fork( ) 配合使用的exec( )。 1、exec( )系列 系 统调用exec( )系列,也可用于新程序的运行。fork( )只是将父进程的用户级上下文拷贝到新进程中,而exec( )系列可以将一个可执行的二进制文件覆盖在新进程的用户级上下文的存储空间上,以更改新进程的用户级上下文。exec( )系列中的系统调用都完成相同的功能,它们把一个新程序装入内存,来改变调用进程的执行代码,从而形成新进程。如果exec( )调用成功,调用进程将被覆盖,然后从新程序的入口开始执行,这样就产生了一个新进程,新进程的进程标识符id 与调用进程相同。 exec( )没有建立一个与调用进程并发的子进程,而是用新进程取代了原来进程。所以exec( )调用成功后,没有任何数据返回,这与fork( )不同。exec( )系列系统调用在UNIX系统库unistd.h中,共有execl、execlp、execle