帮忙解释一下这段代码的意思吧?

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
新office菜鸟
帖子: 293
注册时间: 2010-02-22 17:24

帮忙解释一下这段代码的意思吧?

#1

帖子 新office菜鸟 » 2010-02-23 18:27

请问:
ps -e | grep fcitx (ps -A | grep fcitx)
kill -9 fcitx的pid (pkill -9 fcitx)
fcitx nohup fcitx &

这段代码大体的意思应该是先杀掉fcitx进程,然后再启它,
但我不明白,为什么要用fcitx nohup fcitx &而不直接用fcitx呢?
fcitx后面的nohup是什么意思呀?后面为什么又要多加一个fcitx &呢?
请各位指导一下吧,谢谢了。
头像
xiaomao101
帖子: 474
注册时间: 2006-04-05 18:12
联系:

Re: 帮忙解释一下这段代码的意思吧?

#2

帖子 xiaomao101 » 2010-02-24 2:30

nohup is a POSIX command to ignore the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. The HUP (hangup) signal is by convention the way a terminal warns depending processes of logout.
来自 wikipedia{nohup}
个人觉得“fcitx nohup fcitx &”如果直接输入到终端是不合理的。
这样会造成终端(以后台方式)运行fcitx,然后传递两个参数(其实就是两个字串)“nohup”和“fcitx”给fcitx这个进程。
你可以尝试使用“gedit nohup gedit &”来泡泡看。

“&”是后台运行。
你可以试试
shell> gedit

shell> gedit &
有啥不同,是终端界面上有啥不同,不是gedit这个程序界面上。
更多知识可以google“linux 命令 后台运行”
新office菜鸟
帖子: 293
注册时间: 2010-02-22 17:24

Re: 帮忙解释一下这段代码的意思吧?

#3

帖子 新office菜鸟 » 2010-02-24 13:47

xiaomao101 写了:nohup is a POSIX command to ignore the HUP (hangup) signal, enabling the command to keep running after the user who issues the command has logged out. The HUP (hangup) signal is by convention the way a terminal warns depending processes of logout.
来自 wikipedia{nohup}
个人觉得“fcitx nohup fcitx &”如果直接输入到终端是不合理的。
这样会造成终端(以后台方式)运行fcitx,然后传递两个参数(其实就是两个字串)“nohup”和“fcitx”给fcitx这个进程。
你可以尝试使用“gedit nohup gedit &”来泡泡看。

“&”是后台运行。
你可以试试
shell> gedit

shell> gedit &
有啥不同,是终端界面上有啥不同,不是gedit这个程序界面上。
更多知识可以google“linux 命令 后台运行”
非常感谢大家,
不过有一个地方不明白的,nohup gedit 这两个参数是用来干什么的或?起到什么作用呀?
头像
adagio
论坛版主
帖子: 22110
注册时间: 2008-02-17 23:47
来自: 美丽富饶的那啥星球

Re: 帮忙解释一下这段代码的意思吧?

#4

帖子 adagio » 2010-02-24 13:52

gedit 是一个文本编辑程序,不是参数

nohup类似于把程序变成服务方式运行,这样即使你注销了桌面,fcitx仍然在运行
明天就换大三八!
——8核CPU、8G内存、8T硬盘……
8卡交火,80寸大屏放8个……
IPv8的光纤要8条……

---------------------------------------------------------------------------------
[图片版]新手当自强(续)FAQ
[新手进阶]挂载、fstab、调整linux分区
[图片版]E17桌面环境配置手把手
新office菜鸟
帖子: 293
注册时间: 2010-02-22 17:24

Re: 帮忙解释一下这段代码的意思吧?

#5

帖子 新office菜鸟 » 2010-02-24 13:58

adagio 写了:gedit 是一个文本编辑程序,不是参数

nohup类似于把程序变成服务方式运行,这样即使你注销了桌面,fcitx仍然在运行
非常感谢大家,
“fcitx nohup fcitx &”这里的第二个参数fcitx是何意思呀?或者整段话是什么意思呀?谢谢了。
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: 帮忙解释一下这段代码的意思吧?

#6

帖子 tenzu » 2010-02-24 13:58

加个&足够了吧,还用nohup
头像
xiaomao101
帖子: 474
注册时间: 2006-04-05 18:12
联系:

Re: 帮忙解释一下这段代码的意思吧?

#7

帖子 xiaomao101 » 2010-02-24 16:50

新office菜鸟 写了:
adagio 写了:gedit 是一个文本编辑程序,不是参数

nohup类似于把程序变成服务方式运行,这样即使你注销了桌面,fcitx仍然在运行
非常感谢大家,
“fcitx nohup fcitx &”这里的第二个参数fcitx是何意思呀?或者整段话是什么意思呀?谢谢了。
不好意思没说清楚,叫“参数”容易混淆,还是叫“字符串”吧。
首先,这个“fcitx nohup fcitx &”是你从那里看道的呢?这种写法我觉得有问题(待商榷)。
因为你会发现在终端运行:
shell> fcitx nohup fcitx &
和运行:
shell> fcitx &
这两个效果是一样的。

“fcitx nohup fcitx &”后面的“nohup fcitx”对于你运行fcitx是没有起到作用的。
只有最后的“&”起到了后台运行的作用了。

可以参考bash shell编程学习这些东西。
delectate
帖子: 18311
注册时间: 2008-01-09 22:41

Re: 帮忙解释一下这段代码的意思吧?

#8

帖子 delectate » 2010-02-24 16:53

记得我在原帖回复lz了 :em06

viewtopic.php?f=48&t=257933

11#
头像
xiaomao101
帖子: 474
注册时间: 2006-04-05 18:12
联系:

Re: 帮忙解释一下这段代码的意思吧?

#9

帖子 xiaomao101 » 2010-02-24 16:58

哦,这个“fcitx nohup fcitx &”真的把我搅糊涂了。
delectate
帖子: 18311
注册时间: 2008-01-09 22:41

Re: 帮忙解释一下这段代码的意思吧?

#10

帖子 delectate » 2010-02-24 17:02

xiaomao101 写了:哦,这个“fcitx nohup fcitx &”真的把我搅糊涂了。
my fault

sorry there

it's

代码: 全选

nohup fcitx &
头像
qkbeyond
帖子: 1486
注册时间: 2010-01-03 12:38
来自: 你他妈找死啊
联系:

Re: 帮忙解释一下这段代码的意思吧?

#11

帖子 qkbeyond » 2010-02-24 17:26

不知道 :em06

fcitx也不用非得这么着吧
  • 我希望我的心上人也能理解这一点,这一切的开始并不是为了什么价值、责任、过去或是未来,这一切甚至不是为了现在,这一切只是源于passion。
头像
xiaomao101
帖子: 474
注册时间: 2006-04-05 18:12
联系:

Re: 帮忙解释一下这段代码的意思吧?

#12

帖子 xiaomao101 » 2010-02-24 18:08

delectate 写了:
xiaomao101 写了:哦,这个“fcitx nohup fcitx &”真的把我搅糊涂了。
my fault

sorry there

it's

代码: 全选

nohup fcitx &
呵呵,不过学到一个新的东西nohup
新office菜鸟
帖子: 293
注册时间: 2010-02-22 17:24

Re: 帮忙解释一下这段代码的意思吧?

#13

帖子 新office菜鸟 » 2010-02-24 20:50

delectate 写了:
xiaomao101 写了:哦,这个“fcitx nohup fcitx &”真的把我搅糊涂了。
my fault

sorry there

it's

代码: 全选

nohup fcitx &
谢谢,
fcitx nohup fcitx &”
是否应该写成nohup fcitx &呀?
回复