Skip to content

tib36/SimpleSelfDaemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

SimpleSelfDaemon

单文件自我守护进程的简单demo

(注:目前仅适用于Windows系统)

代码很简单,直接运行该程序会形成守护进程

每隔几秒会检测进程列表,如果子进程不存在则会创建带参数的子进程并记录进程pid

直接运行时为守护进程,带参数运行时为子进程

作为子进程时才执行程序功能,守护进程正常情况下仅监测子进程存活

Example:

PS > go build .\SimpleSelfDaemon.go
PS > .\SimpleSelfDaemon.exe
[*]Process does not exist. Restarting...
[+]Process exists. pid:9896
[+]Process exists. pid:9896
[+]Process exists. pid:9896
[+]Process exists. pid:9896
[+]Process exists. pid:9896
[+]Process exists. pid:9896
[*]Process does not exist. Restarting...
[+]Process exists. pid:11384
[+]Process exists. pid:11384

About

单文件自我守护进程的简单demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages