草庐IT

first-child

全部标签

Linux shell 脚本 : How can I stop a first program when the second will have finished?

我在Linux中有两个程序(例如shell脚本):NeverEnding.shAllwaysEnds.sh第一个永远不会停止,所以我想在后台运行它。第二个停止没有问题。我想制作一个Linuxshell脚本,同时调用它们,但会自动停止(例如,终止)第一个当第二个有完成。如果需要,允许使用特定的命令行工具。 最佳答案 您可以使用&将第一个发送到后台,并通过$!获取它的PID。然后在第二个在前台完成后你可以杀死第一个:#!/bin/bashNeverEnding.sh&pid=$!AllwaysEnds.shkill$pid您实际上不需要

c -/proc/sys/kernel/sched_child_runs_first 工作吗?

我了解到在/proc/sys/kernel/sched_child_runs_first中设置一个非零值将强制子进程在父进程之前运行。但是,我认为它似乎没有用。这是我的代码:#include#includeintmain(intargc,char**argv){pid_tchild_pid;switch(child_pid=fork()){case0:printf("InChild\n");exit(0);case-1:printf("Couldnotfork()\n");default:printf("Inparent\n");}return0;}我得到的输出总是:InparentI

node.js - $first 在 mongodb

我有一个类似的MongoDB查询//Getscoreboardofchallengeresponse.aggregate=awaitScoreBoardModel.aggregate([{$match:{challenge_id:mongoose.Types.ObjectId(req.body.challenge_id)}},{$group:{_id:'$user_id',value:{$sum:'$value'}}},]);哪些输出像[{"_id":"5b762887b6e3a91c60c01718","value":4300},{"_id":"5b8b41f10186400163d

node.js - $first 在 mongodb

我有一个类似的MongoDB查询//Getscoreboardofchallengeresponse.aggregate=awaitScoreBoardModel.aggregate([{$match:{challenge_id:mongoose.Types.ObjectId(req.body.challenge_id)}},{$group:{_id:'$user_id',value:{$sum:'$value'}}},]);哪些输出像[{"_id":"5b762887b6e3a91c60c01718","value":4300},{"_id":"5b8b41f10186400163d

c - 如何从CHILD PROCESS中获取返回值?

程序计算从1到N..子进程计算偶数之和。父进程计算奇数之和。我想在父进程中获取子进程的返回值。我该怎么做#include#include#include#include#includeintmain(){intN;intid;intfd_result;;printf("EnterNtillwhichyouwantthesum:\n");scanf("%d",&N);if((fd_result=creat("result",600))==-1){perror("Errorcreatingfile");exit(1);}if((fd_result=open("result",O_TRUNC

c - 杀死 fork 的 child 会杀死 parent 吗?

我遇到了这种奇怪的行为,我有我的主程序和一个fork的child。它们像这样通过管道传输(数字是文件描述符):___parent___||____child_____|0stdin||||1pipe1[1]----------.|1stdout||2pipe2[1]----------.\|2stderr||____________|\`---------->3pipe1[0]|`---------->5pipe2[0]||______________|因此父级从stdin获取输入,但将stdout和stderr重定向到两个管道。child关闭了它的stdin并改为使用管道的读取端。然

linux - Linux 上的 Swift : Make very first step work

我对swift完全陌生。它刚刚作为Linux的开源软件发布,我想尝试一下。这是在ubuntu14.04上。clang是根据先决条件安装的。:requirementshere在ubuntu14.04上也请求clang版本3.6。我首先使用clang3.4尝试了这些第一步,但后来按照链接中的说明更新到3.6并重试。同样的结果。我已经下载https://swift.org/builds/ubuntu1404/swift-2.2-SNAPSHOT-2015-12-01-b/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04.tar.gz到〜/下载/。安装和s

linux - 等待子进程但出现错误 : 'pid is not a child of this shell'

我写了一个脚本从HDFS并行获取数据,然后我在一个for循环中等待这些子进程,但有时它返回“pid不是这个shell的子进程”。有时,它工作得很好。它很困惑。我使用“jobs-l”来显示在后台运行的所有作业。我确定这些pid是shell进程的子进程,并且我使用“psaux”来确保这些pid没有分配给其他进程。这是我的脚本。PID=()FILE=()letserial=0whilereadindex_tardoecho$index_tar|grepindex>/dev/null2>&1if[[$?-ne0]]thencontinuefisuffix=`printf'%03d'$seria

node.js - MongoDB 与 Docker "failed to connect to server [localhost:27017] on first connect "

我正在使用带有NodeJS后端的mongoDB。问题是我收到以下错误node:16)UnhandledPromiseRejectionWarning:MongoNetworkError:failedtoconnecttoserver[localhost:27017]onfirstconnect[MongoNetworkError:connectECONNREFUSED127.0.0.1:27017]这是我的docker-composeversion:'3.4'services:db:image:mongo:latestports:-'27017:27017'rest-api-node:

node.js - MongoDB 与 Docker "failed to connect to server [localhost:27017] on first connect "

我正在使用带有NodeJS后端的mongoDB。问题是我收到以下错误node:16)UnhandledPromiseRejectionWarning:MongoNetworkError:failedtoconnecttoserver[localhost:27017]onfirstconnect[MongoNetworkError:connectECONNREFUSED127.0.0.1:27017]这是我的docker-composeversion:'3.4'services:db:image:mongo:latestports:-'27017:27017'rest-api-node: