Some misc utility functions


Defines

#define IX_SPAWN_DEFAULT   0
 no specific spawn options
#define IX_SPAWN_SESSION   1
 spawn process as session leader

Functions

int ix_daemon (char *dir)
void * memdup (void *src, size_t len)
char * ix_path (void)
char * ix_stralloc (char *s, int len)
char * ix_strncpy (char *d, char *s, int len)
pid_t ix_spawn (char *cmd, int opt, int f[3], char *env[])
int ix_getpidof (char *proc, pid_t pid[], int maxpid)
 get process id by name
int ix_read_block (int fd, void *buffer, int len, int tio)
int ix_write_block (int sd, void *buffer, int len, int tio)

Function Documentation

int ix_daemon ( char *  dir  ) 

process is set to daemon state

Parameters:
dir if not NULL change current working directory to dir
Returns:
  • 0 OK
  • !0: Error

int ix_getpidof ( char *  proc,
pid_t  pid[],
int  maxpid 
)

get process id by name

get a list of process ids by name

Parameters:
proc process name array of pid to fill maximal number of entries in pid
Returns:
  • number of process found
  • 0 error or no process found

char* ix_path ( void   ) 

returns the ixtools working path

pid_t ix_spawn ( char *  cmd,
int  opt,
int  f[3],
char *  env[] 
)

spawn a new process

Parameters:
cmd process name to start
opt options
f array of open filedescriptors to redirect stdin, stdout, stderr (if not supplied the stdin, stdout and stderr from calling process are inherited)
env null terminated array of environment settings
Returns:
  • pid of new process
  • <=0 error

char* ix_stralloc ( char *  s,
int  len 
)

allocates memory of len+1 bytes and duplicates s

char* ix_strncpy ( char *  d,
char *  s,
int  len 
)

copies s to d but no more than len bytes, ensures that d is zero terminated

void* memdup ( void *  src,
size_t  len 
)

memdup like strdup ;-)


Generated on 4 Mar 2014 for ixtools by  doxygen 1.4.7