codingstandards 发表于 2013-2-4 13:16:30

别忘了在disown之前执行bg命令,否则进程会一直stopped

别忘了在disown之前执行bg命令,否则进程会一直stopped

今天在Linux下测试程序,是直接执行的命令,如下所示:
# ./cap
#======= CAP v20120216f =======#
prog-path: /root/work22/ct08/bin/
prog-name: cap
cfg_name='../cfg/cap.cfg'
loadconfig ok
checkconfig ok
System::Init ok
cap start ok, pid 8342
想到这个程序要在我下班之后继续执行,于是我就按下了Ctrl+Z
 

+  Stopped                 ./cap
 
因为我准备关闭SecureCRT准备收工了,所以决定让它脱离我这个终端,执行了disown来做这件事
# disown %1
-bash: warning: deleting stopped job 1 with process group 8342
#
 
看看这个操作灵不灵,我看了一下日志,发现日志没有继续往下记录,正常情况应该往下记录的。
 
想起来,没有在disown之前执行bg命令,程序已经处于Stopped状态(看disown命令的输出),得让它继续往下执行
 
# killall -CONT cap
 
日志也正常了。切记啊,切记啊:别忘了在disown之前执行bg命令
 
 
本文地址: http://codingstandards.iteye.com/blog/1408321
 
 
相关帮助信息:

# help disown
disown: disown [-h] [-ar]
    By default, removes each JOBSPEC argument from the table of active jobs.
    If the -h option is given, the job is not removed from the table, but is
    marked so that SIGHUP is not sent to the job if the shell receives a
    SIGHUP.  The -a option, when JOBSPEC is not supplied, means to remove all
    jobs from the job table; the -r option means to remove only running jobs.
# help bg
bg: bg
    Place each JOB_SPEC in the background, as if it had been started with
    `&'.  If JOB_SPEC is not present, the shell's notion of the current
    job is used.
# help fg
fg: fg
    Place JOB_SPEC in the foreground, and make it the current job.  If
    JOB_SPEC is not present, the shell's notion of the current job is
    used.
# help jobs
jobs: jobs [-lnprs] or jobs -x command
    Lists the active jobs.  The -l option lists process id's in addition
    to the normal information; the -p option lists process id's only.
    If -n is given, only processes that have changed status since the last
    notification are printed.  JOBSPEC restricts output to that job.  The
    -r and -s options restrict output to running and stopped jobs only,
    respectively.  Without options, the status of all active jobs is
    printed.  If -x is given, COMMAND is run after all job specifications
    that appear in ARGS have been replaced with the process ID of that job's
    process group leader.
#
 
 
 
页: [1]
查看完整版本: 别忘了在disown之前执行bg命令,否则进程会一直stopped