[OE-core] [PATCH 0/1] pseudo: add prefix for log and make log consistent

Robert Yang liezhi.yang at windriver.com
Thu Sep 29 02:31:48 UTC 2016


Hi Peter,

Thanks for the reply, I tested your patch from git repo, it doesn't work,
the message goes to the terminal:
Child process exit status 4: lock_held

diff --git a/pseudo_server.c b/pseudo_server.c
index 8731d20..7c2db2f 100644
--- a/pseudo_server.c
+++ b/pseudo_server.c
@@ -162,6 +162,9 @@ pseudo_server_start(int daemonize) {
          * SIGUSR1, or until too much time has passed. */
         if (daemonize) {
                 int child;
+
+               /* make startup messages go away when invoked-as-daemon */
+               pseudo_debug_logfile(PSEUDO_LOGFILE, 2);
                 child = fork();
                 if (child == -1) {
                         pseudo_diag("Couldn't fork child process: %s\n",
@@ -231,7 +234,6 @@ pseudo_server_start(int daemonize) {
                         setsid();
                         fclose(stdin);
                         fclose(stdout);
-                       pseudo_debug_logfile(PSEUDO_LOGFILE, 2);
                         /* and then just execute the server code normally.  */
                         /* Any logging will presumably go to logfile, but
                          * exit status will make it back to the parent for


the reproducer is:

$ kill -9 `ps aux | grep /usr/bin/pseud | awk '{print $2}'` ; 
/buildarea/lyang1/test_gen/tmp/sysroots/x86_64-linux/usr/bin/pseudo & 
/buildarea/lyang1/test_gen/tmp/sysroots/x86_64-linux/usr/bin/pseudo


And please see my reply inline.

On 09/28/2016 09:25 PM, Seebs wrote:
> On 28 Sep 2016, at 1:22, Robert Yang wrote:
>>
>> meta/recipes-devtools/pseudo/files/0001-pseudo_server.c-add-prefix-for-log-and-make-log-cons.patch
>>
>
> I don't think this produces desireable behavior in the command-line use case; so
> far as I can tell, this would result in getting no messages at all now.
>
> We definitely don't want to unconditionally prepend "pseudo:" to absolutely all
> log messages, that'd be gigabytes of data in a lot of cases. Furthermore,

If there are gigabytes log messages, will 8 characters prefix "pseudo: "
contributes a lot to that ? And I didn't see many log messages when no
errors happen in a normal case (less than 10 lines or 0). "pseudo -x flags"
can produce more, but that is for debugging. I prefer adding prefix to all
the log messages based on the following reasons:
1) Make the log messages unify.
2) It is good for debugging when log messages print on terminal, just like what
    we saw this time (Child process exit status 4: lock_held"
3) How to figure out which one should add prefix, and which one should not ?
    It may cost a lot, but the gain is only for saving 8 characters in a line,
    is it worth ?

// Robert

> pseudo_diag() is sometimes used to produce partial lines. So
>     pseudo_diag("foo: ");
>     pseudo_diag("bar\n");

Should pseudo_diag() be used in this way ? I think no according to other log
utils such as python's logging module.

> would now produce
>     pseudo: foo: pseudo: bar
> which is not desireable. It would make more sense to add the prefix to the
> specific things you're likely to see during startup, of which there's only a few.
>
> I think the right answer probably involves distinguishing between cases where
> we're spawning a daemon because a client has requested one, and command-line
> invocation. This can be partially fixed by moving the pseudo_debug_logfile()
> call up, and making it conditional on opt_d, but then pseudo should also
> probably start a daemon directly (without that) rather than relying
> on the client spawning code when execing something. I can probably fix this
> soonish.
>
> -s
>



More information about the Openembedded-core mailing list