1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
35
#include "sge_shepconf.h"
36
#include "config_file.h"
37
#include "signal_queue.h"
38
#include "sge_signal.h"
39
#include "sge_string.h"
40
#include "err_trace.h"
42
/****** shepherd/shepconf/shepconf_has_userdef_method() ************************
44
* shepconf_has_userdef_method() -- Do we have a user def. method?
47
* int shepconf_has_userdef_method(char *method_name, dstring *method)
50
* Try to find the variable "method_name" in config-file.
51
* Return true and set "method" if it is an absolute path
52
* otherwise return false.
56
* char *method_name - "starter_method", "suspend_method",
57
* "resume_method" or "terminate_method"
58
* dstring *method - Absolut filename of the method
62
*******************************************************************************/
63
int shepconf_has_userdef_method(const char *method_name, dstring *method)
65
char *conf_val = search_nonone_conf_val(method_name);
68
if (conf_val != NULL && conf_val[0] == '/') {
69
sge_dstring_copy_string(method, conf_val);
75
/****** shepherd/shepconf/shepconf_has_userdef_signal() ***********************
77
* shepconf_has_userdef_signal() -- Do we have a user def. signal?
80
* int shepconf_has_userdef_signal(char *method_name, int *signal)
83
* Try to find the variable "method_name" in config-file.
84
* Return true and set "signal" if it is a signal name
85
* otherwise return false.
88
* char *method_name - "starter_method", "suspend_method",
89
* "resume_method" or "terminate_method"
90
* int *signal - signal id
94
*******************************************************************************/
95
int shepconf_has_userdef_signal(const char *method_name, int *signal)
97
char *conf_val = search_nonone_conf_val(method_name);
100
if (conf_val != NULL && conf_val[0] != '/') {
101
*signal = shepherd_sys_str2signal(conf_val);
107
/****** shepherd/shepconf/shepconf_has_notify_signal() ************************
109
* shepconf_has_notify_signal() -- Do we have a notification signal
112
* int shepconf_has_notify_signal(char *notify_name, int *signal)
115
* This function checks if the notification mechanism is enabled.
116
* In this case the function will retuen 'true' and it will
117
* return the default signal or the user defined signal for
118
* the given "notify_name".
121
* char *notify_name - "notify_susp" or "notify_kill"
122
* int *signal - signal id
125
* int - true or false
126
*******************************************************************************/
127
int shepconf_has_notify_signal(const char *notify_name, int *signal)
129
const char *notify_array[] = {
130
"notify_susp", "notify_kill", NULL
132
int signal_array[] = {
135
dstring param_name = DSTRING_INIT;
136
char *conf_type = NULL;
141
* There are three possibilities:
142
* a) There is a user defined signal which should be used
143
* b) Default signal should be used
144
* c) Notification mechanism is disabled
146
sge_dstring_sprintf(¶m_name, "%s%s", notify_name, "_type");
147
conf_type = search_conf_val(sge_dstring_get_string(¶m_name));
148
if (conf_type != NULL) {
149
conf_id = atol(conf_type);
151
conf_id = 1; /* Default signal should be used */
155
char *conf_signal = search_conf_val(notify_name);
157
if (conf_signal != NULL) {
158
*signal = sge_sys_str2signal(conf_signal);
161
} else if (conf_id == 1) {
164
for (i = 0; notify_array[i] != NULL; i++) {
165
if (!strcmp(notify_array[i], notify_name)) {
169
*signal = signal_array[i];
178
/****** shepherd/shepconf/shepconf_has_to_notify_before_signal() **************
180
* shepconf_has_to_notify_before_signal() -- Get notification time
183
* int shepconf_has_to_notify_before_signal(int *seconds)
186
* If the notification mechanism is enabled then this function
187
* will return with "true" and "seconds" will be > 0.
190
* int *seconds - time to elapse between notification and final signal
193
* int - true or false
194
*******************************************************************************/
195
int shepconf_has_to_notify_before_signal(int *seconds)
197
*seconds = atoi(get_conf_val("notify"));
199
return (*seconds > 0);