Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support POSIX basename() from musl libc #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/tini.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
#include <libgen.h>

#include "tiniConfig.h"
#include "tiniLicense.h"
Expand Down Expand Up @@ -224,14 +225,19 @@ int spawn(const signal_configuration_t* const sigconf_ptr, char* const argv[], i
}

void print_usage(char* const name, FILE* const file) {
fprintf(file, "%s (%s)\n", basename(name), TINI_VERSION_STRING);
char *dirc, *bname;

dirc = strdup(name);
bname = basename(dirc);

fprintf(file, "%s (%s)\n", bname, TINI_VERSION_STRING);

#if TINI_MINIMAL
fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", basename(name));
fprintf(file, "Usage: %s PROGRAM [ARGS] | --version\n\n", bname);
#else
fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", basename(name));
fprintf(file, "Usage: %s [OPTIONS] PROGRAM -- [ARGS] | --version\n\n", bname);
#endif
fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", basename(name));
fprintf(file, "Execute a program under the supervision of a valid init process (%s)\n\n", bname);

fprintf(file, "Command line options:\n\n");

Expand Down Expand Up @@ -261,6 +267,7 @@ void print_usage(char* const name, FILE* const file) {
fprintf(file, " %s: Send signals to the child's process group.\n", KILL_PROCESS_GROUP_GROUP_ENV_VAR);

fprintf(file, "\n");
free(dirc);
}

void print_license(FILE* const file) {
Expand Down