Ask Your Question

how to stop dbus-daemon after posix_spawn fork?

asked 2015-11-22 18:32:41 -0500

oddestNeeds gravatar image

updated 2015-11-25 08:04:43 -0500

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.

    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


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 gravatar imageoddestNeeds ( 2016-01-01 06:06:02 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-04-05 00:11:44 -0500

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

Question Tools

1 follower


Asked: 2015-11-22 18:32:41 -0500

Seen: 439 times

Last updated: Apr 05 '16