ndctl, monitor: in daemon mode, exit successfully if no DIMMs are found

When we are running as a daemon, it is preferred to exit successfully
when no DIMMs are found. When running in the foreground, retain an error
return so that the user can be notified that nothing was found to
monitor.

In the longer term, replace this with a libudev uevent monitor that will
look for DIMM addition/removal events, and update the running monitor(s)
if the DIMMs match the active filter spec.

Link: https://bugs.launchpad.net/ubuntu/+source/ndctl/+bug/1781268
Reported-by: Andreas Hasenack <andreas@canonical.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: QI Fuli <qi.fuli@jp.fujitsu.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
diff --git a/ndctl/monitor.c b/ndctl/monitor.c
index 17465bb..b92a133 100644
--- a/ndctl/monitor.c
+++ b/ndctl/monitor.c
@@ -681,8 +681,9 @@
 		goto out;
 
 	if (!mfa.num_dimm) {
-		err((struct ndctl_ctx *)ctx, "no dimms to monitor\n");
-		rc = -ENXIO;
+		dbg((struct ndctl_ctx *)ctx, "no dimms to monitor\n");
+		if (!monitor.daemon)
+			rc = -ENXIO;
 		goto out;
 	}