Staging
v0.5.1
Revision 6327f0efed36c64d98a140110171362b7cb75a52 authored by René Scharfe on 20 January 2022, 12:35:54 UTC, committed by Junio C Hamano on 20 January 2022, 19:07:51 UTC
Document that the accepted variants of the --track option are --track,
--track=direct, and --track=inherit.  The equal sign in the latter two
cannot be replaced with whitespace; in general optional arguments need
to be attached firmly to their option.

Put "direct" consistently before "inherit", if only for the reasons
that the former is the default, explained first in the documentation,
and comes before the latter alphabetically.

Mention both modes in the short help so that readers don't have to look
them up in the full documentation.  They are literal strings and thus
untranslatable.  PARSE_OPT_LITERAL_ARGHELP is inferred due to the pipe
and parenthesis characters, so we don't have to provide that flag
explicitly.

Mention that -t has the same effect as --track and --track=direct.
There is no way to specify inherit mode using the short option, because
short options generally don't accept optional arguments.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 15f0028
Raw File
sigchain.h
#ifndef SIGCHAIN_H
#define SIGCHAIN_H

/**
 * Code often wants to set a signal handler to clean up temporary files or
 * other work-in-progress when we die unexpectedly. For multiple pieces of
 * code to do this without conflicting, each piece of code must remember
 * the old value of the handler and restore it either when:
 *
 *   1. The work-in-progress is finished, and the handler is no longer
 *      necessary. The handler should revert to the original behavior
 *      (either another handler, SIG_DFL, or SIG_IGN).
 *
 *   2. The signal is received. We should then do our cleanup, then chain
 *      to the next handler (or die if it is SIG_DFL).
 *
 * Sigchain is a tiny library for keeping a stack of handlers. Your handler
 * and installation code should look something like:
 *
 * ------------------------------------------
 *   void clean_foo_on_signal(int sig)
 *   {
 * 	  clean_foo();
 * 	  sigchain_pop(sig);
 * 	  raise(sig);
 *   }
 *
 *   void other_func()
 *   {
 * 	  sigchain_push_common(clean_foo_on_signal);
 * 	  mess_up_foo();
 * 	  clean_foo();
 *   }
 * ------------------------------------------
 *
 */

/**
 * Handlers are given the typedef of sigchain_fun. This is the same type
 * that is given to signal() or sigaction(). It is perfectly reasonable to
 * push SIG_DFL or SIG_IGN onto the stack.
 */
typedef void (*sigchain_fun)(int);

/* You can sigchain_push and sigchain_pop individual signals. */
int sigchain_push(int sig, sigchain_fun f);
int sigchain_pop(int sig);

/**
 * push the handler onto the stack for the common signals:
 * SIGINT, SIGHUP, SIGTERM, SIGQUIT and SIGPIPE.
 */
void sigchain_push_common(sigchain_fun f);

void sigchain_pop_common(void);

#endif /* SIGCHAIN_H */
back to top