Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

iv_popen_request_init(3) [debian man page]

iv_popen(3)						    ivykis programmer's manual						       iv_popen(3)

NAME
IV_POPEN_REQUEST_INIT, iv_popen_request_submit, iv_popen_request_close - popen(3) for ivykis applications SYNOPSIS
#include <iv_popen.h> struct iv_popen_request { char *file; char **argv; char *type; }; void IV_POPEN_REQUEST_INIT(struct iv_popen_request *this); int iv_popen_request_submit(struct iv_popen_request *this); void iv_popen_request_close(struct iv_popen_request *this); DESCRIPTION
iv_popen provides ivykis(3) applications with an asynchronous version of popen(3) that is integrated with the ivykis event loop. After initialising a struct iv_popen_request object using IV_POPEN_REQUEST_INIT and assigning its ->file and ->argv and ->type members, one can call iv_popen_request_submit on it to fork off a child process which will call execvp(2) on ->file and ->argv, while in the parent process returning a file descriptor that is connected to the child's standard input (if ->type equals "w") or standard output (if ->type equals "r"). When the application is done with the child process, it should call iv_popen_request_close, and close the file descriptor returned by iv_popen_request_submit (this is not done automatically). iv_popen will continue to monitor the child's process state while it is running, by registering an iv_wait(3) interest for its process ID. If the child process has not yet terminated when iv_popen_request_close is called, iv_popen will attempt to terminate the child process in the background by sending it a series of SIGTERM and SIGKILL signals. iv_popen_request_close must be called from the same thread that iv_popen_request_submit was called from on this object. SEE ALSO
ivykis(3), iv_wait(3), execvp(2), popen(3) ivykis 2010-09-04 iv_popen(3)

Check Out this Related Man Page

iv_wait(3)						    ivykis programmer's manual							iv_wait(3)

NAME
IV_WAIT_INTEREST_INIT, iv_wait_interest_register, iv_wait_interest_register_spawn, iv_wait_interest_unregister, iv_wait_interest_kill - ivykis wait4(2) wrapper SYNOPSIS
#include <iv_wait.h> struct iv_wait_interest { pid_t pid; void *cookie; void (*handler)(void *cookie, int status, struct rusage *rusage); }; void IV_WAIT_INTEREST_INIT(struct iv_wait_interest *this); int iv_wait_interest_register(struct iv_wait_interest *this); int iv_wait_interest_register_spawn(struct iv_wait_interest *this, void (*fn)(void *), void *cookie); void iv_wait_interest_unregister(struct iv_wait_interest *this); int iv_wait_interest_kill(struct iv_wait_interest *this, int sig); DESCRIPTION
iv_wait is an ivykis(3) wrapper around wait4(2), integrating process state change notification with the ivykis event loop. An ivykis application desiring process state change notifications registers a struct iv_wait_interest object by calling iv_wait_inter- est_register, after having initialised it with IV_WAIT_INTEREST_INIT and subsequently having filled in the ->pid, ->cookie and ->handler members. Alternatively, an ivykis application can use iv_wait_interest_register_spawn to atomically fork off a child process and register a struct iv_wait_interest for it. In this context, 'atomically' means that the call to iv_wait_interest_register_spawn will be serialised with respect to invocations of wait4(2), which closes the race where process state change notifications can occur and be delivered between fork- ing off the child process and registering a struct iv_wait_interest for the child's pid. The child process will run the function given by the iv_wait_interest_register_spawn argument fn, with argument cookie as its argument. Once a process state change occurs (as indicated by delivery of a SIGCHLD signal to the current process), iv_wait calls wait4(2) to return information about the process state change, looks up the returned process ID in the set of registered struct iv_wait_interest objects, and if there is a registered interest with a matching ->pid field, arranges for that object's callback function to be called in the thread that the object was registered in. Process state change notifications will continue to be delivered to the object's callback function until iv_wait_interest_unregister is called on the object or until a WIFEXITED or WIFSIGNALED status for this pid is returned by wait4(2). Delivery of a WIFEXITED or WIFSIGNALED status does not automatically unregister the object, this always needs to be done explicitly. Unregistering a struct iv_wait_interest object can only be done from the thread that that object was registered in, but within that thread, can safely be done from (and its underlying memory allocation can safely be freed from) its own callback function. Registering multiple struct iv_wait_interest objects for the same process ID will produce undefined behavior. To send a signal to a child process, use iv_wait_interest_kill. This function will internally serialise with invocations of wait4(2), to avoid the race between sending a signal to a process and collecting a termination notification for that process (which makes its pid avail- able for reuse). Internally, iv_wait is implemented using iv_signal(3) and iv_event(3). SEE ALSO
ivykis(3), iv_signal(3), iv_event(3), wait4(2) ivykis 2010-09-03 iv_wait(3)
Man Page