守护程序和正常进程之间在行为上有什么区别? [英] What are the behavioral differences between a daemon and a normal process?

查看:86
本文介绍了守护程序和正常进程之间在行为上有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道守护进程主要在后台运行,即它们需要用户的交互很少.

I know that daemons run in the background mostly i.e. they require very less interaction from the user.

维基百科列表一些常见的守护程序类型:

Wikipedia lists some of the types of daemons that commonly exist:

  • 与控制tty脱离
  • 成为会议负责人
  • 成为流程组负责人
  • 通过分叉和退出(一次或两次)停留在后台.有时,这是使该过程成为会话主持人所必需的.它还允许父进程继续其正常执行.有时会用分叉而死"来概括这个成语
  • 将根目录("/")设置为当前工作目录,以便该进程不会保留任何正在使用的目录,该目录可能在已挂载的文件系统上(允许将其卸载).
  • 将umask更改为0以允许open(),creat()等.调用以提供自己的权限掩码,而不依赖于调用者的umask
  • 在执行时关闭所有由父进程保持打开状态的继承打开文件,包括文件描述符0、1和2(stdin,stdout,stderr).所需的文件将在以后打开.
  • 使用日志文件,控制台或/dev/null作为stdin,stdout和stderr

除了第一行中提到的内容外,我想知道守护进程中的行为是否与正常进程有所不同.这两种过程都可以完成工作,并根据用户完成工作所需的交互量与用户交互.

I want to know if there can be any differences in behavior in a daemon as differentiated from a normal process, apart from the one I mentioned in the first line. Both kinds of processes do their work, and interact with the user depending on the amount of interaction they need to do their job.

守护进程是否比这更多?

Is there more to daemons than this?

推荐答案

不是.守护程序只是一个连续运行的过程的术语,通常不附加在终端上.

Not really. A daemon is just a term for a process that runs continuously and usually is not attached to a terminal.

守护进程不是独立的进程类,它们没有特殊的特权或属性.

Daemons are not a separate class of processes and they have no special privileges or attributes.

有一个名为daemon的BSD/Linux C函数(手册页) ,但这实际上是将您的流程与其终端分离的一种简单方法.之所以这样命名,是因为守护进程通常这样做,而不是相反.

There is a BSD/Linux C function called daemon (man page), but this is just really a simple way to detach your process from its terminal. It is so named because that's what daemons usually do, not the other way around.

这篇关于守护程序和正常进程之间在行为上有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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