child-process

Don't send SIGINT on CTRL+C to child processes but don't ignore the signal itself

那年仲夏 提交于 2021-02-08 03:44:30
问题 I'm trying to write a Task control program, very much like Supervisor. I run some programs from a config file and let them run in the background, while in the main process I read and execute other commands. Before fork() -ing, in the main process I call: sigaction(SIGINT, &the_handler, NULL); Where the_handler stores the reference of a simple print function. When CTRL+C is pressed, the child processes are interrupted as well (which I don't want). I could run: signal(SIGINT, SIG_IGN); after

Don't send SIGINT on CTRL+C to child processes but don't ignore the signal itself

不想你离开。 提交于 2021-02-08 03:44:01
问题 I'm trying to write a Task control program, very much like Supervisor. I run some programs from a config file and let them run in the background, while in the main process I read and execute other commands. Before fork() -ing, in the main process I call: sigaction(SIGINT, &the_handler, NULL); Where the_handler stores the reference of a simple print function. When CTRL+C is pressed, the child processes are interrupted as well (which I don't want). I could run: signal(SIGINT, SIG_IGN); after

How does one automatically attach a debugger to a process at process start on OS X?

戏子无情 提交于 2021-02-07 19:22:29
问题 I have a process that spawns a helper process. Sometimes I need to debug start-up failures in the second process. On Windows, I would use Image File Execution Options , or ntsd -o . However, I have no idea how to do this with gdb on OS X. 回答1: Use gdb --wait. For example, try gdb --wait TextEdit from the command line, then launch TextEdit. 回答2: I don't think that you can have gdb launch in the same manner. Instead, run your parent process from within gdb or attach to the running process

How does one automatically attach a debugger to a process at process start on OS X?

99封情书 提交于 2021-02-07 19:22:12
问题 I have a process that spawns a helper process. Sometimes I need to debug start-up failures in the second process. On Windows, I would use Image File Execution Options , or ntsd -o . However, I have no idea how to do this with gdb on OS X. 回答1: Use gdb --wait. For example, try gdb --wait TextEdit from the command line, then launch TextEdit. 回答2: I don't think that you can have gdb launch in the same manner. Instead, run your parent process from within gdb or attach to the running process

Buffer returned by child_process.execSync is incomplete

随声附和 提交于 2021-02-07 03:19:42
问题 I have the following script which executes a shell command: #!/usr/bin/env node const { execSync } = require('child_process'); try { const data = execSync( 'yarn licenses generate-disclaimer --prod', { encoding: 'utf8', maxBuffer: 50 * 1024 * 1024 } ); console.log(data.length); return true; } catch (error) { console.error(`Failed to generate disclaimer: ${error.message}`); return false; } data is a Buffer containing stdout of the child process. As I understand, the way to convert it to a

Buffer returned by child_process.execSync is incomplete

不羁的心 提交于 2021-02-07 03:17:10
问题 I have the following script which executes a shell command: #!/usr/bin/env node const { execSync } = require('child_process'); try { const data = execSync( 'yarn licenses generate-disclaimer --prod', { encoding: 'utf8', maxBuffer: 50 * 1024 * 1024 } ); console.log(data.length); return true; } catch (error) { console.error(`Failed to generate disclaimer: ${error.message}`); return false; } data is a Buffer containing stdout of the child process. As I understand, the way to convert it to a

Buffer returned by child_process.execSync is incomplete

冷暖自知 提交于 2021-02-07 03:16:56
问题 I have the following script which executes a shell command: #!/usr/bin/env node const { execSync } = require('child_process'); try { const data = execSync( 'yarn licenses generate-disclaimer --prod', { encoding: 'utf8', maxBuffer: 50 * 1024 * 1024 } ); console.log(data.length); return true; } catch (error) { console.error(`Failed to generate disclaimer: ${error.message}`); return false; } data is a Buffer containing stdout of the child process. As I understand, the way to convert it to a

Child process setInterval sporadically not firing

时间秒杀一切 提交于 2021-01-29 08:08:21
问题 My application places bets on certain sporting events. Almost like an automatic betting bot. A part of this is to track the current status of the event so it can make an informed calculation whether to place a bet or not. To do this, I poll the status of an event every minute using setInterval . A single sporting event is "watched" by 1 child process. There could be up 100+ sporting events at any one time meaning there could be 100+ child process' spawned & actively polling. worker/index.js

Is there a reason for the child to not to print until the parent process finishes printing?

大兔子大兔子 提交于 2021-01-28 10:48:00
问题 #include <stdio.h> #include <unistd.h> int do_fork(int depth) { if (!depth) { return fork(); } int val = do_fork(depth - 1); printf("%d\n", val); return val; } int main() { int val; scanf("%d", &val); do_fork(val); } I tried this code several times, with several different values on several different machines. It doesn't matter how big the number is, I always see the pid of the child printed one next to the other with no zeros in between. Only when the pids are all printed, the child starts

node.js spawn stdout string broken when received

别来无恙 提交于 2021-01-28 10:41:17
问题 I have the following python code (script.py): import sys import numpy as np from scipy import stats def generateBeta() : fit = (0.075252656968743836, 498.49505071718869, 9.9999999999999991e-05, 0.18136881492296397) rnd = stats.beta.rvs(fit[0], fit[1], fit[2], fit[3], 581) rndStr = "" for i in rnd: rndStr += str(i) + ',' print rndStr[0:len(rndStr)-1] if __name__ =='__main__' : generateBeta() When running "python script.py" I get something like: 0.000461650100253,0.000100731728317,0