5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <alloca.h>
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <libscf.h>
32 #include <priv_utils.h>
33 #include <netdb.h>
34 #include <signal.h>
35 #include <strings.h>
36 #include <time.h>
37 #include <unistd.h>
38 #include <zone.h>
39 #include <sys/types.h>
40 #include <sys/stat.h>
41 #include <fm/fmd_msg.h>
42 #include <fm/libfmevent.h>
43 #include "libfmnotify.h"
44
794 get_svc_config();
795
796 /*
797 * In the case where we get started outside of SMF, args passed on the
798 * command line override SMF property setting
799 */
800 while (optind < argc) {
801 while ((c = getopt(argc, argv, optstr)) != -1) {
802 switch (c) {
803 case 'd':
804 nhdl->nh_debug = B_TRUE;
805 break;
806 case 'f':
807 run_fg = B_TRUE;
808 break;
809 case 'R':
810 nhdl->nh_rootdir = strdup(optarg);
811 break;
812 default:
813 free(nhdl);
814 return (usage(nhdl->nh_pname));
815 }
816 }
817 }
818
819 /*
820 * Set up a signal handler for SIGTERM (and SIGINT if we'll
821 * be running in the foreground) to ensure sure we get a chance to exit
822 * in an orderly fashion. We also catch SIGHUP, which will be sent to
823 * us by SMF if the service is refreshed.
824 */
825 (void) sigfillset(&set);
826 (void) sigfillset(&act.sa_mask);
827 act.sa_handler = nd_sighandler;
828 act.sa_flags = 0;
829
830 (void) sigaction(SIGTERM, &act, NULL);
831 (void) sigdelset(&set, SIGTERM);
832 (void) sigaction(SIGHUP, &act, NULL);
833 (void) sigdelset(&set, SIGHUP);
834
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 /*
27 * Copyright (c) 2018, Joyent, Inc.
28 */
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <alloca.h>
34 #include <errno.h>
35 #include <fcntl.h>
36 #include <libscf.h>
37 #include <priv_utils.h>
38 #include <netdb.h>
39 #include <signal.h>
40 #include <strings.h>
41 #include <time.h>
42 #include <unistd.h>
43 #include <zone.h>
44 #include <sys/types.h>
45 #include <sys/stat.h>
46 #include <fm/fmd_msg.h>
47 #include <fm/libfmevent.h>
48 #include "libfmnotify.h"
49
799 get_svc_config();
800
801 /*
802 * In the case where we get started outside of SMF, args passed on the
803 * command line override SMF property setting
804 */
805 while (optind < argc) {
806 while ((c = getopt(argc, argv, optstr)) != -1) {
807 switch (c) {
808 case 'd':
809 nhdl->nh_debug = B_TRUE;
810 break;
811 case 'f':
812 run_fg = B_TRUE;
813 break;
814 case 'R':
815 nhdl->nh_rootdir = strdup(optarg);
816 break;
817 default:
818 free(nhdl);
819 return (usage(argv[0]));
820 }
821 }
822 }
823
824 /*
825 * Set up a signal handler for SIGTERM (and SIGINT if we'll
826 * be running in the foreground) to ensure sure we get a chance to exit
827 * in an orderly fashion. We also catch SIGHUP, which will be sent to
828 * us by SMF if the service is refreshed.
829 */
830 (void) sigfillset(&set);
831 (void) sigfillset(&act.sa_mask);
832 act.sa_handler = nd_sighandler;
833 act.sa_flags = 0;
834
835 (void) sigaction(SIGTERM, &act, NULL);
836 (void) sigdelset(&set, SIGTERM);
837 (void) sigaction(SIGHUP, &act, NULL);
838 (void) sigdelset(&set, SIGHUP);
839
|