openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/misc-utils/uuidd.c
static int create_socket(struct uuidd_cxt_t* uuidd_cxt, const char* socket_path,
                         int will_fork)
{
    struct sockaddr_un my_addr;
    mode_t save_umask;
    int s;

    if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
    {
        if (!uuidd_cxt->quiet)
            warn(_("couldn't create unix stream socket"));
        exit(EXIT_FAILURE);
    }

    /*
     * Make sure the socket isn't using fd numbers 0-2 to avoid it
     * getting closed by create_daemon()
     */
    while (will_fork && s <= 2)
    {
        s = dup(s);
        if (s < 0)
            err(EXIT_FAILURE, "dup");
    }

    /*
     * Create the address we will be binding to.
     */
    my_addr.sun_family = AF_UNIX;
    assert(strlen(socket_path) < sizeof(my_addr.sun_path));
    xstrncpy(my_addr.sun_path, socket_path, sizeof(my_addr.sun_path));
    unlink(socket_path);
    save_umask = umask(0);
    if (bind(s, (const struct sockaddr*)&my_addr, sizeof(struct sockaddr_un)) <
        0)
    {
        if (!uuidd_cxt->quiet)
            warn(_("couldn't bind unix socket %s"), socket_path);
        exit(EXIT_FAILURE);
    }
    umask(save_umask);
    uuidd_cxt->cleanup_socket = socket_path;

    return s;
}
/*
 * Create AF_UNIX, SOCK_STREAM socket and bind to @socket_path
 *
 * If @will_fork is true, then make sure the descriptor
 * of the socket is >2, so that it won't be later closed
 * during create_daemon().
 *
 * Return file descriptor corresponding to created socket.
 */
Create AF_UNIX, SOCK_STREAM socket and bind to @socket_path
If @will_fork is true, then make sure the descriptor
of the socket is >2, so that it won't be later closed
during create_daemon().

Return file descriptor corresponding to created socket.
Create AF_UNIX SOCK_STREAM socket and bind to @socket_path If @will_fork is true then make sure the descriptor of the socket is > 2 so that it won ' t be later closed during create_daemon () . Return file descriptor corresponding to created socket .
static int create_socket(struct uuidd_cxt_t* uuidd_cxt, const char* socket_path,
                         int will_fork)
{
    struct sockaddr_un my_addr;
    mode_t save_umask;
    int s;
    if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
    {
        if (!uuidd_cxt->quiet)
            warn(_("couldn't create unix stream socket"));
        exit(EXIT_FAILURE);
    }
    while (will_fork && s <= 2)
    {
        s = dup(s);
        if (s < 0)
            err(EXIT_FAILURE, "dup");
    }
    my_addr.sun_family = AF_UNIX;
    assert(strlen(socket_path) < sizeof(my_addr.sun_path));
    xstrncpy(my_addr.sun_path, socket_path, sizeof(my_addr.sun_path));
    unlink(socket_path);
    save_umask = umask(0);
    if (bind(s, (const struct sockaddr*)&my_addr, sizeof(struct sockaddr_un)) <
        0)
    {
        if (!uuidd_cxt->quiet)
            warn(_("couldn't bind unix socket %s"), socket_path);
        exit(EXIT_FAILURE);
    }
    umask(save_umask);
    uuidd_cxt->cleanup_socket = socket_path;
    return s;
}
static int create_socket ( struct uuidd_cxt_t * uuidd_cxt , const char * socket_path , int will_fork ) { struct sockaddr_un my_addr ; mode_t save_umask ; int s ; if ( ( s = socket ( AF_UNIX , SOCK_STREAM , 0 ) ) < 0 ) { if ( ! uuidd_cxt -> quiet ) warn ( _ ( " " ) ) ; exit ( EXIT_FAILURE ) ; } while ( will_fork && s <= 2 ) { s = dup ( s ) ; if ( s < 0 ) err ( EXIT_FAILURE , " " ) ; } my_addr . sun_family = AF_UNIX ; assert ( strlen ( socket_path ) < sizeof ( my_addr . sun_path ) ) ; xstrncpy ( my_addr . sun_path , socket_path , sizeof ( my_addr . sun_path ) ) ; unlink ( socket_path ) ; save_umask = umask ( 0 ) ; if ( bind ( s , ( const struct sockaddr * ) & my_addr , sizeof ( struct sockaddr_un ) ) < 0 ) { if ( ! uuidd_cxt -> quiet ) warn ( _ ( " " ) , socket_path ) ; exit ( EXIT_FAILURE ) ; } umask ( save_umask ) ; uuidd_cxt -> cleanup_socket = socket_path ; return s ; }
Create AF_UNIX, SOCK_STREAM socket and bind to @socket_path
 If @will_fork is true, then make sure the descriptor
 of the socket is >2, so that it won't be later closed
 during create_daemon().
Create AF_UNIX SOCK_STREAM socket and bind to @socket_path If @will_fork is true then make sure the descriptor of the socket is > 2 so that it won ' t be later closed during create_daemon () .
/*
     * Make sure the socket isn't using fd numbers 0-2 to avoid it
     * getting closed by create_daemon()
     */ /*
     * Create the address we will be binding to.
     */