Skip to content

margo_finalize hangs if the process was forked #303

@mdorier

Description

@mdorier

In the following program, the child process hangs on margo_finalize. It only happens if the instance uses a progress thread.

#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <margo.h>

int main(int argc, char** argv) {

    pid_t pid = getpid();
    printf("%d: before margo_init\n", pid);
    margo_instance_id mid = margo_init("na+sm", MARGO_CLIENT_MODE, true, 0);

    printf("%d: before fork\n", pid);
    pid_t p = fork();
    if(p < 0 ) {
      perror("fork fail");
      exit(1);
    }

    pid = getpid();
    printf("%d: before margo_finalize\n", pid);
    margo_finalize(mid);

    printf("%d: before wait\n", pid);
    if(p > 0) wait(NULL);

    printf("%d: all done\n", pid);
    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions