📄 apr__thread__proc_8h-source.html
字号:
00602 <span class="comment"> * </PRE></span>
00603 <span class="comment"> * @param waithow How should we wait. One of:</span>
00604 <span class="comment"> * <PRE></span>
00605 <span class="comment"> * APR_WAIT -- block until the child process dies.</span>
00606 <span class="comment"> * APR_NOWAIT -- return immediately regardless of if the </span>
00607 <span class="comment"> * child is dead or not.</span>
00608 <span class="comment"> * </PRE></span>
00609 <span class="comment"> * @remark The childs status is in the return code to this process. It is one of:</span>
00610 <span class="comment"> * <PRE></span>
00611 <span class="comment"> * APR_CHILD_DONE -- child is no longer running.</span>
00612 <span class="comment"> * APR_CHILD_NOTDONE -- child is still running.</span>
00613 <span class="comment"> * </PRE></span>
00614 <span class="comment"> */</span>
00615 APR_DECLARE(apr_status_t) apr_proc_wait(<a class="code" href="structapr__proc__t.html">apr_proc_t</a> *proc,
00616 <span class="keywordtype">int</span> *exitcode, apr_exit_why_e *exitwhy,
00617 apr_wait_how_e waithow);
00618 <span class="comment"></span>
00619 <span class="comment">/**</span>
00620 <span class="comment"> * Wait for any current child process to die and return information </span>
00621 <span class="comment"> * about that child.</span>
00622 <span class="comment"> * @param proc Pointer to NULL on entry, will be filled out with child's </span>
00623 <span class="comment"> * information </span>
00624 <span class="comment"> * @param exitcode The returned exit status of the child, if a child process </span>
00625 <span class="comment"> * dies, or the signal that caused the child to die.</span>
00626 <span class="comment"> * On platforms that don't support obtaining this information, </span>
00627 <span class="comment"> * the status parameter will be returned as APR_ENOTIMPL.</span>
00628 <span class="comment"> * @param exitwhy Why the child died, the bitwise or of:</span>
00629 <span class="comment"> * <PRE></span>
00630 <span class="comment"> * APR_PROC_EXIT -- process terminated normally</span>
00631 <span class="comment"> * APR_PROC_SIGNAL -- process was killed by a signal</span>
00632 <span class="comment"> * APR_PROC_SIGNAL_CORE -- process was killed by a signal, and</span>
00633 <span class="comment"> * generated a core dump.</span>
00634 <span class="comment"> * </PRE></span>
00635 <span class="comment"> * @param waithow How should we wait. One of:</span>
00636 <span class="comment"> * <PRE></span>
00637 <span class="comment"> * APR_WAIT -- block until the child process dies.</span>
00638 <span class="comment"> * APR_NOWAIT -- return immediately regardless of if the </span>
00639 <span class="comment"> * child is dead or not.</span>
00640 <span class="comment"> * </PRE></span>
00641 <span class="comment"> * @param p Pool to allocate child information out of.</span>
00642 <span class="comment"> * @bug Passing proc as a *proc rather than **proc was an odd choice</span>
00643 <span class="comment"> * for some platforms... this should be revisited in 1.0</span>
00644 <span class="comment"> */</span>
00645 APR_DECLARE(apr_status_t) apr_proc_wait_all_procs(<a class="code" href="structapr__proc__t.html">apr_proc_t</a> *proc,
00646 <span class="keywordtype">int</span> *exitcode,
00647 apr_exit_why_e *exitwhy,
00648 apr_wait_how_e waithow,
00649 apr_pool_t *p);
00650
<a name="l00651"></a><a class="code" href="group__apr__thread__proc.html#ga66">00651</a> #define APR_PROC_DETACH_FOREGROUND 0 <span class="comment">/**< Do not detach */</span>
<a name="l00652"></a><a class="code" href="group__apr__thread__proc.html#ga67">00652</a> #define APR_PROC_DETACH_DAEMONIZE 1 <span class="comment">/**< Detach */</span>
00653 <span class="comment"></span>
00654 <span class="comment">/**</span>
00655 <span class="comment"> * Detach the process from the controlling terminal.</span>
00656 <span class="comment"> * @param daemonize set to non-zero if the process should daemonize</span>
00657 <span class="comment"> * and become a background process, else it will</span>
00658 <span class="comment"> * stay in the foreground.</span>
00659 <span class="comment"> */</span>
00660 APR_DECLARE(apr_status_t) apr_proc_detach(<span class="keywordtype">int</span> daemonize);
00661 <span class="comment"></span>
00662 <span class="comment">/**</span>
00663 <span class="comment"> * Register an other_child -- a child associated to its registered </span>
00664 <span class="comment"> * maintence callback. This callback is invoked when the process</span>
00665 <span class="comment"> * dies, is disconnected or disappears.</span>
00666 <span class="comment"> * @param proc The child process to register.</span>
00667 <span class="comment"> * @param maintenance maintenance is a function that is invoked with a </span>
00668 <span class="comment"> * reason and the data pointer passed here.</span>
00669 <span class="comment"> * @param data Opaque context data passed to the maintenance function.</span>
00670 <span class="comment"> * @param write_fd An fd that is probed for writing. If it is ever unwritable</span>
00671 <span class="comment"> * then the maintenance is invoked with reason </span>
00672 <span class="comment"> * OC_REASON_UNWRITABLE.</span>
00673 <span class="comment"> * @param p The pool to use for allocating memory.</span>
00674 <span class="comment"> * @bug write_fd duplicates the proc->out stream, it's really redundant</span>
00675 <span class="comment"> * and should be replaced in the APR 1.0 API with a bitflag of which</span>
00676 <span class="comment"> * proc->in/out/err handles should be health checked.</span>
00677 <span class="comment"> * @bug no platform currently tests the pipes health.</span>
00678 <span class="comment"> */</span>
00679 APR_DECLARE(<span class="keywordtype">void</span>) apr_proc_other_child_register(<a class="code" href="structapr__proc__t.html">apr_proc_t</a> *proc,
00680 <span class="keywordtype">void</span> (*maintenance) (<span class="keywordtype">int</span> reason,
00681 <span class="keywordtype">void</span> *,
00682 <span class="keywordtype">int</span> status),
00683 <span class="keywordtype">void</span> *data, apr_file_t *write_fd,
00684 apr_pool_t *p);
00685 <span class="comment"></span>
00686 <span class="comment">/**</span>
00687 <span class="comment"> * Stop watching the specified other child. </span>
00688 <span class="comment"> * @param data The data to pass to the maintenance function. This is</span>
00689 <span class="comment"> * used to find the process to unregister.</span>
00690 <span class="comment"> * @warning Since this can be called by a maintenance function while we're</span>
00691 <span class="comment"> * scanning the other_children list, all scanners should protect </span>
00692 <span class="comment"> * themself by loading ocr->next before calling any maintenance </span>
00693 <span class="comment"> * function.</span>
00694 <span class="comment"> */</span>
00695 APR_DECLARE(<span class="keywordtype">void</span>) apr_proc_other_child_unregister(<span class="keywordtype">void</span> *data);
00696 <span class="comment"></span>
00697 <span class="comment">/**</span>
00698 <span class="comment"> * Notify the maintenance callback of a registered other child process</span>
00699 <span class="comment"> * that application has detected an event, such as death.</span>
00700 <span class="comment"> * @param proc The process to check</span>
00701 <span class="comment"> * @param reason The reason code to pass to the maintenance function</span>
00702 <span class="comment"> * @param status The status to pass to the maintenance function</span>
00703 <span class="comment"> * @remark An example of code using this behavior;</span>
00704 <span class="comment"> * <pre></span>
00705 <span class="comment"> * rv = apr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p);</span>
00706 <span class="comment"> * if (APR_STATUS_IS_CHILD_DONE(rv)) {</span>
00707 <span class="comment"> * #if APR_HAS_OTHER_CHILD</span>
00708 <span class="comment"> * if (apr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status)</span>
00709 <span class="comment"> * == APR_SUCCESS) {</span>
00710 <span class="comment"> * ; (already handled)</span>
00711 <span class="comment"> * }</span>
00712 <span class="comment"> * else</span>
00713 <span class="comment"> * #endif</span>
00714 <span class="comment"> * [... handling non-otherchild processes death ...]</span>
00715 <span class="comment"> * </pre></span>
00716 <span class="comment"> */</span>
00717 APR_DECLARE(apr_status_t) apr_proc_other_child_alert(<a class="code" href="structapr__proc__t.html">apr_proc_t</a> *proc,
00718 <span class="keywordtype">int</span> reason,
00719 <span class="keywordtype">int</span> status);
00720 <span class="comment"></span>
00721 <span class="comment">/**</span>
00722 <span class="comment"> * Test one specific other child processes and invoke the maintenance callback </span>
00723 <span class="comment"> * with the appropriate reason code, if still running, or the appropriate reason </span>
00724 <span class="comment"> * code if the process is no longer healthy.</span>
00725 <span class="comment"> * @param ocr The registered other child</span>
00726 <span class="comment"> * @param reason The reason code (e.g. APR_OC_REASON_RESTART) if still running</span>
00727 <span class="comment"> */</span>
00728 APR_DECLARE(<span class="keywordtype">void</span>) apr_proc_other_child_refresh(apr_other_child_rec_t *ocr,
00729 <span class="keywordtype">int</span> reason);
00730 <span class="comment"></span>
00731 <span class="comment">/**</span>
00732 <span class="comment"> * Test all registered other child processes and invoke the maintenance callback </span>
00733 <span class="comment"> * with the appropriate reason code, if still running, or the appropriate reason </span>
00734 <span class="comment"> * code if the process is no longer healthy.</span>
00735 <span class="comment"> * @param reason The reason code (e.g. APR_OC_REASON_RESTART) to running processes</span>
00736 <span class="comment"> */</span>
00737 APR_DECLARE(<span class="keywordtype">void</span>) apr_proc_other_child_refresh_all(<span class="keywordtype">int</span> reason);
00738 <span class="comment"></span>
00739 <span class="comment">/** </span>
00740 <span class="comment"> * Terminate a process.</span>
00741 <span class="comment"> * @param proc The process to terminate.</span>
00742 <span class="comment"> * @param sig How to kill the process.</span>
00743 <span class="comment"> */</span>
00744 APR_DECLARE(apr_status_t) apr_proc_kill(<a class="code" href="structapr__proc__t.html">apr_proc_t</a> *proc, <span class="keywordtype">int</span> sig);
00745 <span class="comment"></span>
00746 <span class="comment">/**</span>
00747 <span class="comment"> * Register a process to be killed when a pool dies.</span>
00748 <span class="comment"> * @param a The pool to use to define the processes lifetime </span>
00749 <span class="comment"> * @param proc The process to register</span>
00750 <span class="comment"> *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -