logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

notcurses_fds - dumping file descriptors and subprocesses to planes

Authors

       nick black <nickblack@linux.com>.

                                                     v3.0.7                                     notcurses_fds(3)

Description

       These  widgets  cause  a  file  descriptor to be read until EOF, and written to a scrolling ncplane.  The
       reading will take place in a notcurses-managed context (the particulars of this context are not  defined,
       and  should  not  be depended upon), which will invoke the provided callbacks with the data read.  Essen‐
       tially, they are simply portable interfaces to asynchronous reading, with ncsubproc also  providing  sub‐
       process management.

       If  ncsubproc_destroy  is  called before the subprocess has exited, it will be sent a SIGKILL.  If ncsub‐proc_destroy or ncfdplane_destroy is called while a callback is being invoked, the destroy function  will
       block  until  the  callback  is done being invoked.  If a user callback returns non-0, the calling object
       will destroy itself.  If a user callback calls the relevant destroy function itself, the thread will exit
       as if non-0 had been returned, and the ncsubproc's resources will at that time be reclaimed.

       It is essential that the destroy function be called once and only once, whether it  is  from  within  the
       thread's context, or external to that context.

Name

       notcurses_fds - dumping file descriptors and subprocesses to planes

Notes

ncsubproc  makes  use of pidfds and pidfd_send_signal(2), and thus makes reliable use of signals (it will
       never target a process other than the true subprocess).

Return Values

See Also

pidfd_open(2), notcurses(3), notcurses_plane(3)

Synopsis

#include<notcurses/notcurses.h>

              struct ncplane;
              struct ncfdplane;
              struct ncsubproc;

              typedef struct ncfdplane_options {
                void* curry; // parameter provided to callbacks
                bool follow; // keep reading after hitting end?
              } ncfdplane_options;

              typedef struct ncsubproc_options {
                void* curry; // parameter provided to callbacks
                uint64_t restart_period;  // restart after exit
              } ncsubproc_options;

       typedefint(ncfdplane_callback)(structncfdplanen,constvoid*buf,size_ts,void*curry);typedefint(ncfdplane_done_cb)(structncfdplanen,intfderrno,void*curry);structncfdplane*ncfdplane_create(structncplane*n,constncfdplane_options*opts,intfd,ncfd‐plane_callbackcbfxn,ncfdplane_done_cbdonecbfxn);structncplane*ncfdplane_plane(structncfdplane*n);intncfdplane_destroy(structncfdplane*n);structncsubproc*ncsubproc_createv(structncplane*n,constncsubproc_options*opts,constchar*bin,char*constarg[],ncfdplane_callbackcbfxn,ncfdplane_done_cbdonecbfxn);structncsubproc*ncsubproc_createvp(structncplane*n,constncsubproc_options*opts,constchar*bin,char*constarg[],ncfdplane_callbackcbfxn,ncfdplane_done_cbdonecbfxn);structncsubproc*ncsubproc_createvpe(structncplane*n,constncsubproc_options*opts,constchar*bin,char*constarg[],char*constenv[],ncfdplane_callbackcbfxn,ncfdplane_done_cbdonecbfxn);structncplane*ncsubproc_plane(structncsubproc*n);intncsubproc_destroy(structncsubproc*n);

See Also