1 /* 2 * (c) Copyright 1990, Kim Fabricius Storm. All rights reserved. 3 * Copyright (c) 1996-2005 Michael T Pins. All rights reserved. 4 * 5 * Master/slave communication and locking. 6 */ 7 8 /* 9 * proto_lock() modes 10 */ 11 12 #include <stdio.h> 13 14 #define PL_SET 1 /* set lock (if not set) */ 15 #define PL_SET_WAIT 2 /* set lock (wait until set) */ 16 #define PL_SET_QUICK 3 /* as _WAIT, but using sleep(1) */ 17 #define PL_CLEAR 4 /* clear lock */ 18 #define PL_CLEAR_WAIT 5 /* wait for lock to disappear */ 19 #define PL_CHECK 6 /* check running status */ 20 #define PL_WAKEUP 7 /* send wakeup (must succeed) */ 21 #define PL_WAKEUP_SOFT 8 /* send wakeup (may fail) */ 22 #define PL_TERMINATE 9 /* send termination */ 23 #define PL_TRANSFER 10 /* transfer lock to current process (forked) */ 24 25 /* 26 * types for send_master(type, group, opt, arg) 27 */ 28 29 #define SM_SET_OPTION 'O' /* set option to arg (toggle if -1) */ 30 #define SM_SET_FLAG 'F' /* opt=set/clear flag 'arg' in group */ 31 #define SM_RECOLLECT 'R' /* recollect group (or all groups if NULL) */ 32 #define SM_EXPIRE 'X' /* expire group (or all groups if NULL) */ 33 #define SM_SCAN_ONCE 'U' /* scan unconditionally (ignore active) */ 34 35 int proto_lock(int, int); 36 FILE *open_gate_file(int); 37 void send_master(char, group_header *, int, long); 38