Rizin
unix-like reverse engineering framework and cli tools
bsd-proctitle.c File Reference
#include "uv.h"
#include "internal.h"
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Functions

static void init_process_title_mutex_once (void)
 
void uv__process_title_cleanup (void)
 
char ** uv_setup_args (int argc, char **argv)
 
int uv_set_process_title (const char *title)
 
int uv_get_process_title (char *buffer, size_t size)
 

Variables

static uv_mutex_t process_title_mutex
 
static uv_once_t process_title_mutex_once = UV_ONCE_INIT
 
static char * process_title
 

Function Documentation

◆ init_process_title_mutex_once()

static void init_process_title_mutex_once ( void  )
static

Definition at line 34 of file bsd-proctitle.c.

34  {
36  abort();
37 }
static uv_mutex_t process_title_mutex
Definition: bsd-proctitle.c:29
UV_EXTERN int uv_mutex_init(uv_mutex_t *handle)
Definition: thread.c:282

References process_title_mutex, and uv_mutex_init().

Referenced by uv_get_process_title(), and uv_set_process_title().

◆ uv__process_title_cleanup()

void uv__process_title_cleanup ( void  )

Definition at line 40 of file bsd-proctitle.c.

40  {
41  /* TODO(bnoordhuis) uv_mutex_destroy(&process_title_mutex)
42  * and reset process_title_mutex_once?
43  */
44 }

◆ uv_get_process_title()

int uv_get_process_title ( char *  buffer,
size_t  size 
)

Definition at line 73 of file bsd-proctitle.c.

73  {
74  size_t len;
75 
76  if (buffer == NULL || size == 0)
77  return UV_EINVAL;
78 
81 
82  if (process_title != NULL) {
83  len = strlen(process_title) + 1;
84 
85  if (size < len) {
87  return UV_ENOBUFS;
88  }
89 
91  } else {
92  len = 0;
93  }
94 
96 
97  buffer[len] = '\0';
98 
99  return 0;
100 }
size_t len
Definition: 6502dis.c:15
static void init_process_title_mutex_once(void)
Definition: bsd-proctitle.c:34
static uv_once_t process_title_mutex_once
Definition: bsd-proctitle.c:30
static char * process_title
Definition: bsd-proctitle.c:31
#define NULL
Definition: cris-opc.c:27
voidpf void uLong size
Definition: ioapi.h:138
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
Definition: buffer.h:15
UV_EXTERN void uv_mutex_lock(uv_mutex_t *handle)
Definition: thread.c:330
UV_EXTERN void uv_once(uv_once_t *guard, void(*callback)(void))
Definition: thread.c:419
UV_EXTERN void uv_mutex_unlock(uv_mutex_t *handle)
Definition: thread.c:350

References init_process_title_mutex_once(), len, memcpy(), NULL, process_title, process_title_mutex, process_title_mutex_once, uv_mutex_lock(), uv_mutex_unlock(), and uv_once().

◆ uv_set_process_title()

int uv_set_process_title ( const char *  title)

Definition at line 53 of file bsd-proctitle.c.

53  {
54  char* new_title;
55 
56  new_title = uv__strdup(title);
57  if (new_title == NULL)
58  return UV_ENOMEM;
59 
62 
64  process_title = new_title;
65  setproctitle("%s", title);
66 
68 
69  return 0;
70 }
int void setproctitle(const char *name,...)
char * uv__strdup(const char *s)
Definition: uv-common.c:55
void uv__free(void *ptr)
Definition: uv-common.c:81

References init_process_title_mutex_once(), NULL, process_title, process_title_mutex, process_title_mutex_once, setproctitle(), uv__free(), uv__strdup(), uv_mutex_lock(), uv_mutex_unlock(), and uv_once().

◆ uv_setup_args()

char** uv_setup_args ( int  argc,
char **  argv 
)

Definition at line 47 of file bsd-proctitle.c.

47  {
48  process_title = argc > 0 ? uv__strdup(argv[0]) : NULL;
49  return argv;
50 }
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40

References argv, NULL, process_title, and uv__strdup().

Variable Documentation

◆ process_title

char* process_title
static

Definition at line 31 of file bsd-proctitle.c.

Referenced by uv_get_process_title(), uv_set_process_title(), and uv_setup_args().

◆ process_title_mutex

uv_mutex_t process_title_mutex
static

◆ process_title_mutex_once

uv_once_t process_title_mutex_once = UV_ONCE_INIT
static

Definition at line 30 of file bsd-proctitle.c.

Referenced by uv_get_process_title(), and uv_set_process_title().