简体   繁体   中英

Running daemon as regular application (debugging in KDevelop)

There are tools that enable one to run a console command or a console application as a daemon. To "daemonize" it, so to say.

Is there a way to run a daemon as a regular console application?

I'm coding in KDevelop and don't see any options for daemon debugging.

Thanks !

It's reasonably normal to add a special debugging mode to daemons to enable this. That is, add in a command-line option to disable the daemonizing step, having the program run in the foreground. Then it is is simple to run the daemon under gdb.

I'm not aware of any generic way to do this. Maybe it could be done somehow with LD_PRELOAD interception, which would be cool -- but it's simpler to just modify the source.

For debugging a running daemon you can use the gdb attach command. However this is not very good for debugging daemon startup, as you'll have to race to attach in time.

The linux kernel doesn't support any way to "pre-attach" to the next instance of a program, but I wrote a hack to do it via SystemTap that you can find here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM