ksh脚本生成具有相同名称的不需要的子级 [英] ksh script spawns unwanted child with the same name

查看:54
本文介绍了ksh脚本生成具有相同名称的不需要的子级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以..我在Solaris8上使用KSH的时间很长,但这是我第一次得到这样的内容:

So.. I use KSH on Solaris8 for quite long but this is the first time I got something like this:

我启动一个脚本-我们称它为splitCfg.当我调用pgrep -x splitCfg时,我发现此脚本的两个实例-主实例和我的脚本的子实例(来自ps的输出):

I start a script - let's call it splitCfg. When I call pgrep -x splitCfg I'm finding two instances of this script - the main instance and a child of my script (output from ps):

root 28069 25107  0 20:22:01 pts/10   0:00 splitCfg
root  4668 28069  0 20:22:50 pts/10   0:00 splitCfg

如您所见-第一个实例是孩子的父母.但是-没有从主脚本创建的子进程.当我再一次调用ps或pgrep或ptree时,我得到: 1.没有子进程 或者 2.一个新的子进程

As you can see - the first instance is a parent for a child. However - there is no subprocess created from the main script. When I call the ps or pgrep or ptree one more time I get: 1. no child process or 2. a new child process

我正在寻找一些解释.我相信我已经搜索了整个Internet,所以是时候向大家询问您的宝贵时间了:)

I am looking for some explanation. I believe I've search whole Internet, so it's time to ask all of you for some of your precious time :)

是某种KSH错误(请注意,我使用的是Solaris 8的较旧版本)还是缺少某些内容.我知道单个脚本应该创建一个PID,并在完成时将其保留.

Is it some sort of the KSH bug (note that I'm using pretty old version from Solaris 8) or am I missing something. I understand that single script should create a single PID and leave it when it finishes.

谢谢, 开胃菜

推荐答案

如果您的Shell脚本中带有括号,则根据您所使用的ksh版本,该子Shell可以在单独的Unix进程中运行.我认为ksh88i(一个非常旧的版本)仍作为Solaris上的系统外壳发布.

If you have parenthesis in your shell script, the subshell may run in a separate Unix process, depending on what ksh version you have. I think ksh88i (a very old version) is still shipping as the system shell on Solaris.

这篇关于ksh脚本生成具有相同名称的不需要的子级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆