fork

Sharing data across processes on linux

﹥>﹥吖頭↗ 提交于 2020-01-02 05:41:10
问题 In my application, I have a process which forks off a child, say child1, and this child process writes a huge binary file on the disk and exits. The parent process then forks off another child process, child2, which reads in this huge file to do further processing. The file dumping and re-loading is making my application slow and I'm thinking of possible ways of avoiding disk I/O completely. Possible ways I have identified are ram-disk or tmpfs. Can I somehow implement ram-disk or tmpfs from

perl fork doesn't work properly when run remotely (via ssh)

Deadly 提交于 2020-01-02 05:09:10
问题 I have a perl script, script.pl which, when run, does a fork, the parent process outputs its pid to a file then exits while the child process outputs something to STOUT and then goes into a while loop. $pid = fork(); if ( ! defined $pid ) { die "Failed to fork."; } #Parent process elsif($pid) { if(!open (PID, ">>running_PIDs")) { warn "Error opening file to append PID"; } print PID "$pid \n"; close PID; } #child process else { print "Output started"; while($loopControl) { #Do some stuff } }

Multithreaded C program; how to kill processes spawned by threads?

烂漫一生 提交于 2020-01-01 11:52:27
问题 Situation: I am writing a program in C that maintains a number of threads. Once a thread ends, a new one is created. Each thread forks - the child runs a process via exec() and the parent waits for it to finish. In addition, there is a signal handler thread that waits for signals. If SIGINT is detected then it tells the main thread to stop creating threads so eventually all the threads end and the program can exit. Signals are blocked in all threads except of course the signal handler thread.

How can I timeout a forked process that might hang?

跟風遠走 提交于 2020-01-01 03:12:08
问题 I am writing a Perl script that will write some inputs and send those inputs to an external program. There is a small but non-zero chance that this program will hang, and I want to time it out: my $pid = fork; if ($pid > 0){ eval{ local $SIG{ALRM} = sub { die "TIMEOUT!"}; alarm $num_secs_to_timeout; waitpid($pid, 0); alarm 0; }; } elsif ($pid == 0){ exec('echo blahblah | program_of_interest'); exit(0); } As it stands now, after $num_secs_to_timeout, program_of_interest still persists. I tried

python | Linux的上的MongoDB的安装与卸载

巧了我就是萌 提交于 2020-01-01 01:50:26
安装 1.下载安装包 wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz 下载完成后解压缩压缩包 tar zxf mongodb-linux-i686-1.8.2.tgz 2.安装准备 将MongoDB中移动到在/ usr /本地/服务器/ mongdb文件夹 mv mongodb-linux-i686-1.8.2 /usr/local/mongodb 创建数据库文件夹与日志文件 mkdir /usr/local/mongodb/data touch /usr/local/mongodb/logs 3.设置开机自启动 将MongoDB的启动项目追加入rc.local中保证的MongoDB在服务器开机时启动 echo "/usr/local/server/mongodb/bin/mongod --dbpath=/usr/local/server/mongodb/data –logpath=/usr/local/server/mongodb/logs –logappend --auth –port=27017" >>/etc/rc.local 启动mongodb cd到mongodb目录下的bin文件夹启动mongodb //下面这个是需要权限的登录方式,用户连接需要用户名和密码 /usr/local

Multiclient server using fork()

可紊 提交于 2019-12-31 08:43:21
问题 I am trying to create a socket programming server to handle multiple clients at the same time using fork().. But I am not able to implement it properly.I have been trying for a long time . The problems I am facing are 1) address bind problem 2) problem how to handle parent process and child process 3) how to end the server program ie ..return to the console My programs for a single client server were working properly.Here is my code for the multiple client-server. #include<signal.h> #include

Multiclient server using fork()

↘锁芯ラ 提交于 2019-12-31 08:43:09
问题 I am trying to create a socket programming server to handle multiple clients at the same time using fork().. But I am not able to implement it properly.I have been trying for a long time . The problems I am facing are 1) address bind problem 2) problem how to handle parent process and child process 3) how to end the server program ie ..return to the console My programs for a single client server were working properly.Here is my code for the multiple client-server. #include<signal.h> #include

Multiclient server using fork()

喜夏-厌秋 提交于 2019-12-31 08:43:00
问题 I am trying to create a socket programming server to handle multiple clients at the same time using fork().. But I am not able to implement it properly.I have been trying for a long time . The problems I am facing are 1) address bind problem 2) problem how to handle parent process and child process 3) how to end the server program ie ..return to the console My programs for a single client server were working properly.Here is my code for the multiple client-server. #include<signal.h> #include

Multiclient server using fork()

可紊 提交于 2019-12-31 08:42:27
问题 I am trying to create a socket programming server to handle multiple clients at the same time using fork().. But I am not able to implement it properly.I have been trying for a long time . The problems I am facing are 1) address bind problem 2) problem how to handle parent process and child process 3) how to end the server program ie ..return to the console My programs for a single client server were working properly.Here is my code for the multiple client-server. #include<signal.h> #include

The purpose of the wait() in parent c

我只是一个虾纸丫 提交于 2019-12-31 05:38:10
问题 I am new to processes in linux and c. I am using this straightforward example: #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, const char * argv[]) { pid_t child_pid_or_zero = fork(); //fork returns twice if(child_pid_or_zero < 0) { //if fork returns a number smaller than zero, something wrong happened perror("Something wrong happened\n"); exit(-1); } if(child_pid_or_zero > 0) { //if fork returns a number greater than zero, this is the parent process printf("I'm