English
Ask Your Question
0

how to stop dbus-daemon after posix_spawn fork?

asked 2015-11-23 00:32:41 +0000

oddestNeeds gravatar image

updated 2015-11-25 14:04:43 +0000

The posix_spawn arguments are a mystery to me, I use these, and could use advice, however, my real problem is this little server I have set up to spawn programs has worked flawlessly for years, but with fedora 22, it now spawns a dbus-daemon on every launch, which I then must clean up manually using the system-monitor.

How do I shut down the dbus-daemon when the the forked process closes, or, alternatively, how do I use a single dbus-daemon for the forked processes? dbus-daemon is also a mystery to me, fyi.

Note: the code sample provided was edited to remove my macros, & I hope it's translation to recognizable "C" is correct, but, its a standard fork.

Thanks Very much for all suggestions.

ons   
    pid_t pid; 
 /* signal( SIGCHLD, SIG_IGN );*/
    struct sigaction arg={ SIG_IGN, SA_NOCLDWAIT // never wait for a child. //( for direct termination of children )
    };
    sigaction( SIGCHLD, &arg, NULL );
    if( ( pid= fork() ) < 0 ) {
        yas( "fork failed\n" );
        exit( 1 );
    else  if (  pid== 0 ) {
        char buf[ 4096 ];
        getcwd( buf, 4096 );
        chdir( runDir );
        CHP spaArgs[] = { runCmd, runArgs, NULL };
        CHP spaEnv[] = { "USERNAME="
        ,  "USER=" 
        ,  "PATH=" 
        ,  "LD_LIBRARY_PATH=" 
        ,  "DISPLAY=:0" 
        ,  "DESKTOP_SESSION=gnome" 
        ,  "HOME=" 
        ,  "XAUTHORITY=/run/user/1000/gdm/Xauthority" 
        , NULL };

        YAS( "The Parent process id is" +IST( getpid() ) );

        INT err=posix_spawn( &pid, spaArgs[ 0 ], NULL, NULL, spaArgs, spaEnv );

        if( err )  YAZ( SIM( err ) ) ;
        exit( 0 );
    }
    int waitPIDerr= waitpid( pid, NULL, 0 /* WNOHANG */ );
    if( waitPIDerr )  YAZ( SIM( waitPIDerr ) );
edit retag flag offensive close merge delete

Comments

I also have a lot of sockets I open & close between applications. Might it be possible the dbus-daemon doesn't close because of pending sockets?

oddestNeeds ( 2016-01-01 12:06:02 +0000 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-04-05 05:11:44 +0000

oddestNeeds gravatar image

The only answer I could find to this question was to run a clean-up script. That's what I did.

I put a .desktop file in the autostart directory to

(1) record the pids of the dbus-daemons at boot time. (2) launch a bash script to periodically kill any dbus-daemons not in the original list.

My apps run just fine without them.

I'd still prefer if my applications did not launch the unneeded daemons, but, I haven't a clue as to how to do it

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Use your votes!

  • Use the 30 daily voting points that you get!
  • Up-vote well framed questions that provide enough information to enable people provide answers.
  • Thank your helpers by up-voting their comments and answers. If a question you asked has been answered, accept the best answer by clicking on the checkbox on the left side of the answer.
  • Down-voting might cost you karma, but you should consider doing so for incorrect or clearly detrimental questions and answers.

Question Tools

Follow
1 follower

Stats

Asked: 2015-11-23 00:32:41 +0000

Seen: 187 times

Last updated: Apr 05 '16