How to detect if running in daemon?

I have a plugin which provides several tasks which have problems when running in daemon mode. Until I have time to fix the underlying problem, I want to log a warning that running in daemon mode may cause problems.

How can a task detect that it’s running in a daemon? I found this question on SO, but parsing stack traces and launcher command seems fragile. Is there a better way?