fork

Fork, execlp and kill. Zombie process

ぃ、小莉子 提交于 2021-02-20 04:13:06
问题 I have a c program that executes another process (bash script) with fork and execlp. When I want to kill this process it moves to a zombiee state. Why is this?? Create a process: switch (PID_BackUp= fork()) { case -1: perror("fork"); printf("An error has occurred launching backup.sh script!\n"); break; case 0: execlp("/usr/local/bin/backup.sh", "/usr/local/bin/backup.sh", NULL, NULL, NULL); break; default: printf("backup.sh script launched correctly! PID: %d\n", PID_BackUp); break; } Kill a

getline() is repeatedly reading the file, when fork() is used

和自甴很熟 提交于 2021-02-19 11:01:42
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN

getline() is repeatedly reading the file, when fork() is used

白昼怎懂夜的黑 提交于 2021-02-19 10:55:37
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN

getline() is repeatedly reading the file, when fork() is used

白昼怎懂夜的黑 提交于 2021-02-19 10:50:13
问题 I am developing a simple shell program, a command line interpreter and I wanted to read input from the file line by line, so I used getline() function. At the first time, the program works correctly, however, when it reaches the end of the file, instead of terminating, it starts to read a file from the start and it runs infinitely. Here are some codes in main function that are related to getline(): int main(int argc,char *argv[]){ int const IN_SIZE = 255; char *input = NULL; size_t len = IN

What's the equivalence of os.fork() on Windows with Python? [duplicate]

倾然丶 夕夏残阳落幕 提交于 2021-02-18 17:51:07
问题 This question already has answers here : What's the best way to duplicate fork() in windows? (7 answers) Closed 1 year ago . This code works well in Mac/Linux, but not in Windows. import mmap import os map = mmap.mmap(-1, 13) map.write("Hello world!") pid = os.fork() if pid == 0: # In a child process print 'child' map.seek(0) print map.readline() map.close() else: print 'parent' What's the equivalent function of os.fork() on Windows? 回答1: Depending on your use case and whether you can use

What's the equivalence of os.fork() on Windows with Python? [duplicate]

为君一笑 提交于 2021-02-18 17:51:00
问题 This question already has answers here : What's the best way to duplicate fork() in windows? (7 answers) Closed 1 year ago . This code works well in Mac/Linux, but not in Windows. import mmap import os map = mmap.mmap(-1, 13) map.write("Hello world!") pid = os.fork() if pid == 0: # In a child process print 'child' map.seek(0) print map.readline() map.close() else: print 'parent' What's the equivalent function of os.fork() on Windows? 回答1: Depending on your use case and whether you can use

Using cd command with fork in c

爱⌒轻易说出口 提交于 2021-02-17 05:15:39
问题 Is it possible to change around directories using the fork command? Without going too much into my code I have the following: childpid = fork(); if (childpid >= 0) { if (childpid == 0) { ret = execvp(argv[0],argv); exit(ret); } else { waitpid(childpid,&status,0); ret = WEXITSTATUS(status); } } The above works fine when I'm entering basic command like ls , pwd , etc.. Is it possible to implement a way to use the cd function? I can type the command cd .. but it doesn't do anything. For example

New Microsoft Edge and Selenium web driver

偶尔善良 提交于 2021-02-11 14:48:05
问题 I am a student and I started writing my first scripts using Ruby, Capybara, rspec and selenium web driver. I need to run my script in all modern browsers, but I'm facing some problems to run my script at the new Microsoft browser Edge. My rspec config is something like this: Capybara.configure do |config| config.default_driver = :selenium #This line is for run tests using Mozilla Firefox #config.default_driver = :selenium_chrome #This line is for run tests using Google Chrome end Edge is just

How would you fork an AWS CodeCommit repo to another CodeCommit repo?

我只是一个虾纸丫 提交于 2021-02-11 12:53:45
问题 In github there is a fork button to fork a repo into a new repo you control. According to are git forks actually git clones? a github fork is a clone on the server side. If you read the git-scm documentation it specifically says to click the fork button in Github. I assume because there is no fork button in AWS CodeCommit there is not similar functionality. So, is there a way to do this with the native git cli? 回答1: I don't think there is any option in AWS CodeCommit to fork. What you can do

Posix_spawn performance when capturing process output

人走茶凉 提交于 2021-02-11 06:22:57
问题 I am trying to use posix_spawn instead of fork/exec to get some performance gain. My current project is written in Python, so I used this Python binding. Also I tried some of its forks, and after that I wrote my own posix_spawn binding in Cython (to get rid of some dependencies), but obtained almost the same results. There is indeed a significant speed-up when I just need to run processes without capturing stdout/stderr. But when I do need it (for my project it is necessary), the posix_spawn