Linux Audio

Check our new training course

Loading...
v6.2
  1// SPDX-License-Identifier: GPL-2.0-or-later
  2/*
  3 * tmon.c Thermal Monitor (TMON) main function and entry point
  4 *
  5 * Copyright (C) 2012 Intel Corporation. All rights reserved.
  6 *
 
 
 
 
 
 
 
 
 
  7 * Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
 
  8 */
  9
 10#include <getopt.h>
 11#include <unistd.h>
 12#include <stdio.h>
 13#include <stdlib.h>
 14#include <string.h>
 15#include <sys/types.h>
 16#include <sys/stat.h>
 17#include <ncurses.h>
 18#include <ctype.h>
 19#include <time.h>
 20#include <signal.h>
 21#include <limits.h>
 22#include <sys/time.h>
 23#include <pthread.h>
 24#include <math.h>
 25#include <stdarg.h>
 26#include <syslog.h>
 27
 28#include "tmon.h"
 29
 30unsigned long ticktime = 1; /* seconds */
 31unsigned long no_control = 1; /* monitoring only or use cooling device for
 32			       * temperature control.
 33			       */
 34double time_elapsed = 0.0;
 35unsigned long target_temp_user = 65; /* can be select by tui later */
 36int dialogue_on;
 37int tmon_exit;
 38static short	daemon_mode;
 39static int logging; /* for recording thermal data to a file */
 40static int debug_on;
 41FILE *tmon_log;
 42/*cooling device used for the PID controller */
 43char ctrl_cdev[CDEV_NAME_SIZE] = "None";
 44int target_thermal_zone; /* user selected target zone instance */
 45static void	start_daemon_mode(void);
 46
 47pthread_t event_tid;
 48pthread_mutex_t input_lock;
 49void usage(void)
 50{
 51	printf("Usage: tmon [OPTION...]\n");
 52	printf("  -c, --control         cooling device in control\n");
 53	printf("  -d, --daemon          run as daemon, no TUI\n");
 54	printf("  -g, --debug           debug message in syslog\n");
 55	printf("  -h, --help            show this help message\n");
 56	printf("  -l, --log             log data to /var/tmp/tmon.log\n");
 57	printf("  -t, --time-interval   sampling time interval, > 1 sec.\n");
 58	printf("  -T, --target-temp     initial target temperature\n");
 59	printf("  -v, --version         show version\n");
 60	printf("  -z, --zone            target thermal zone id\n");
 61
 62	exit(0);
 63}
 64
 65void version(void)
 66{
 67	printf("TMON version %s\n", VERSION);
 68	exit(EXIT_SUCCESS);
 69}
 70
 71static void tmon_cleanup(void)
 72{
 
 73	syslog(LOG_INFO, "TMON exit cleanup\n");
 74	fflush(stdout);
 75	refresh();
 76	if (tmon_log)
 77		fclose(tmon_log);
 78	if (event_tid) {
 79		pthread_mutex_lock(&input_lock);
 80		pthread_cancel(event_tid);
 81		pthread_mutex_unlock(&input_lock);
 82		pthread_mutex_destroy(&input_lock);
 83	}
 84	closelog();
 85	/* relax control knobs, undo throttling */
 86	set_ctrl_state(0);
 87
 88	keypad(stdscr, FALSE);
 89	echo();
 90	nocbreak();
 91	close_windows();
 92	endwin();
 93	free_thermal_data();
 94
 95	exit(1);
 96}
 97
 
 98static void tmon_sig_handler(int sig)
 99{
100	syslog(LOG_INFO, "TMON caught signal %d\n", sig);
101	refresh();
102	switch (sig) {
103	case SIGTERM:
104		printf("sigterm, exit and clean up\n");
105		fflush(stdout);
106		break;
107	case SIGKILL:
108		printf("sigkill, exit and clean up\n");
109		fflush(stdout);
110		break;
111	case SIGINT:
112		printf("ctrl-c, exit and clean up\n");
113		fflush(stdout);
114		break;
115	default:
116		break;
117	}
118	tmon_exit = true;
119}
120
 
121static void start_syslog(void)
122{
123	if (debug_on)
124		setlogmask(LOG_UPTO(LOG_DEBUG));
125	else
126		setlogmask(LOG_UPTO(LOG_ERR));
127	openlog("tmon.log", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
128	syslog(LOG_NOTICE, "TMON started by User %d", getuid());
129}
130
131static void prepare_logging(void)
132{
133	int i;
134	struct stat logstat;
135
136	if (!logging)
137		return;
138	/* open local data log file */
139	tmon_log = fopen(TMON_LOG_FILE, "w+");
140	if (!tmon_log) {
141		syslog(LOG_ERR, "failed to open log file %s\n", TMON_LOG_FILE);
142		return;
143	}
144
145	if (lstat(TMON_LOG_FILE, &logstat) < 0) {
146		syslog(LOG_ERR, "Unable to stat log file %s\n", TMON_LOG_FILE);
147		fclose(tmon_log);
148		tmon_log = NULL;
149		return;
150	}
151
152	/* The log file must be a regular file owned by us */
153	if (S_ISLNK(logstat.st_mode)) {
154		syslog(LOG_ERR, "Log file is a symlink.  Will not log\n");
155		fclose(tmon_log);
156		tmon_log = NULL;
157		return;
158	}
159
160	if (logstat.st_uid != getuid()) {
161		syslog(LOG_ERR, "We don't own the log file.  Not logging\n");
162		fclose(tmon_log);
163		tmon_log = NULL;
164		return;
165	}
166
 
167	fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n");
168	for (i = 0; i < ptdata.nr_tz_sensor; i++) {
169		char binding_str[33]; /* size of long + 1 */
170		int j;
171
172		memset(binding_str, 0, sizeof(binding_str));
173		for (j = 0; j < 32; j++)
174			binding_str[j] = (ptdata.tzi[i].cdev_binding & (1 << j)) ?
175				'1' : '0';
176
177		fprintf(tmon_log, "#thermal zone %s%02d cdevs binding: %32s\n",
178			ptdata.tzi[i].type,
179			ptdata.tzi[i].instance,
180			binding_str);
181		for (j = 0; j <	ptdata.tzi[i].nr_trip_pts; j++) {
182			fprintf(tmon_log, "#\tTP%02d type:%s, temp:%lu\n", j,
183				trip_type_name[ptdata.tzi[i].tp[j].type],
184				ptdata.tzi[i].tp[j].temp);
185		}
 
186	}
187
188	for (i = 0; i <	ptdata.nr_cooling_dev; i++)
189		fprintf(tmon_log, "#cooling devices%02d: %s\n",
190			i, ptdata.cdi[i].type);
191
192	fprintf(tmon_log, "#---------- THERMAL DATA LOG STARTED -----------\n");
193	fprintf(tmon_log, "Samples TargetTemp ");
194	for (i = 0; i < ptdata.nr_tz_sensor; i++) {
195		fprintf(tmon_log, "%s%d    ", ptdata.tzi[i].type,
196			ptdata.tzi[i].instance);
197	}
198	for (i = 0; i <	ptdata.nr_cooling_dev; i++)
199		fprintf(tmon_log, "%s%d ", ptdata.cdi[i].type,
200			ptdata.cdi[i].instance);
201
202	fprintf(tmon_log, "\n");
203}
204
205static struct option opts[] = {
206	{ "control", 1, NULL, 'c' },
207	{ "daemon", 0, NULL, 'd' },
208	{ "time-interval", 1, NULL, 't' },
209	{ "target-temp", 1, NULL, 'T' },
210	{ "log", 0, NULL, 'l' },
211	{ "help", 0, NULL, 'h' },
212	{ "version", 0, NULL, 'v' },
213	{ "debug", 0, NULL, 'g' },
214	{ 0, 0, NULL, 0 }
215};
216
 
217int main(int argc, char **argv)
218{
219	int err = 0;
220	int id2 = 0, c;
221	double yk = 0.0, temp; /* controller output */
222	int target_tz_index;
223
224	if (geteuid() != 0) {
225		printf("TMON needs to be run as root\n");
226		exit(EXIT_FAILURE);
227	}
228
229	while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
230		switch (c) {
231		case 'c':
232			no_control = 0;
233			strncpy(ctrl_cdev, optarg, CDEV_NAME_SIZE);
234			break;
235		case 'd':
236			start_daemon_mode();
237			printf("Run TMON in daemon mode\n");
238			break;
239		case 't':
240			ticktime = strtod(optarg, NULL);
241			if (ticktime < 1)
242				ticktime = 1;
243			break;
244		case 'T':
245			temp = strtod(optarg, NULL);
246			if (temp < 0) {
247				fprintf(stderr, "error: temperature must be positive\n");
248				return 1;
249			}
250			target_temp_user = temp;
251			break;
252		case 'l':
253			printf("Logging data to /var/tmp/tmon.log\n");
254			logging = 1;
255			break;
256		case 'h':
257			usage();
258			break;
259		case 'v':
260			version();
261			break;
262		case 'g':
263			debug_on = 1;
264			break;
265		case 'z':
266			target_thermal_zone = strtod(optarg, NULL);
267			break;
268		default:
269			break;
270		}
271	}
272	if (pthread_mutex_init(&input_lock, NULL) != 0) {
273		fprintf(stderr, "\n mutex init failed, exit\n");
274		return 1;
275	}
276	start_syslog();
277	if (signal(SIGINT, tmon_sig_handler) == SIG_ERR)
278		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
279	if (signal(SIGTERM, tmon_sig_handler) == SIG_ERR)
280		syslog(LOG_DEBUG, "Cannot handle SIGTERM\n");
281
282	if (probe_thermal_sysfs()) {
283		pthread_mutex_destroy(&input_lock);
284		closelog();
285		return -1;
286	}
287	initialize_curses();
288	setup_windows();
289	signal(SIGWINCH, resize_handler);
290	show_title_bar();
291	show_sensors_w();
292	show_cooling_device();
293	update_thermal_data();
294	show_data_w();
295	prepare_logging();
296	init_thermal_controller();
297
298	nodelay(stdscr, TRUE);
299	err = pthread_create(&event_tid, NULL, &handle_tui_events, NULL);
300	if (err != 0) {
301		printf("\ncan't create thread :[%s]", strerror(err));
302		tmon_cleanup();
303		exit(EXIT_FAILURE);
304	}
305
306	/* validate range of user selected target zone, default to the first
307	 * instance if out of range
308	 */
309	target_tz_index = zone_instance_to_index(target_thermal_zone);
310	if (target_tz_index < 0) {
311		target_thermal_zone = ptdata.tzi[0].instance;
312		syslog(LOG_ERR, "target zone is not found, default to %d\n",
313			target_thermal_zone);
314	}
315	while (1) {
316		sleep(ticktime);
317		show_title_bar();
318		show_sensors_w();
319		update_thermal_data();
320		if (!dialogue_on) {
321			show_data_w();
322			show_cooling_device();
323		}
 
324		time_elapsed += ticktime;
325		controller_handler(trec[0].temp[target_tz_index] / 1000, &yk);
 
326		trec[0].pid_out_pct = yk;
327		if (!dialogue_on)
328			show_control_w();
329		if (tmon_exit)
330			break;
331	}
332	tmon_cleanup();
333	return 0;
334}
335
336static void start_daemon_mode(void)
337{
338	daemon_mode = 1;
339	/* fork */
340	pid_t	sid, pid = fork();
341
342	if (pid < 0)
343		exit(EXIT_FAILURE);
344	else if (pid > 0)
345		/* kill parent */
346		exit(EXIT_SUCCESS);
347
348	/* disable TUI, it may not be necessary, but saves some resource */
349	disable_tui();
350
351	/* change the file mode mask */
352	umask(S_IWGRP | S_IWOTH);
353
354	/* new SID for the daemon process */
355	sid = setsid();
356	if (sid < 0)
357		exit(EXIT_FAILURE);
358
359	/* change working directory */
360	if ((chdir("/")) < 0)
361		exit(EXIT_FAILURE);
362
 
363	sleep(10);
364
365	close(STDIN_FILENO);
366	close(STDOUT_FILENO);
367	close(STDERR_FILENO);
 
368}
v4.6
 
  1/*
  2 * tmon.c Thermal Monitor (TMON) main function and entry point
  3 *
  4 * Copyright (C) 2012 Intel Corporation. All rights reserved.
  5 *
  6 * This program is free software; you can redistribute it and/or
  7 * modify it under the terms of the GNU General Public License version
  8 * 2 or later as published by the Free Software Foundation.
  9 *
 10 * This program is distributed in the hope that it will be useful,
 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 * GNU General Public License for more details.
 14 *
 15 * Author: Jacob Pan <jacob.jun.pan@linux.intel.com>
 16 *
 17 */
 18
 19#include <getopt.h>
 20#include <unistd.h>
 21#include <stdio.h>
 22#include <stdlib.h>
 23#include <string.h>
 24#include <sys/types.h>
 25#include <sys/stat.h>
 26#include <ncurses.h>
 27#include <ctype.h>
 28#include <time.h>
 29#include <signal.h>
 30#include <limits.h>
 31#include <sys/time.h>
 32#include <pthread.h>
 33#include <math.h>
 34#include <stdarg.h>
 35#include <syslog.h>
 36
 37#include "tmon.h"
 38
 39unsigned long ticktime = 1; /* seconds */
 40unsigned long no_control = 1; /* monitoring only or use cooling device for
 41			       * temperature control.
 42			       */
 43double time_elapsed = 0.0;
 44unsigned long target_temp_user = 65; /* can be select by tui later */
 45int dialogue_on;
 46int tmon_exit;
 47static short	daemon_mode;
 48static int logging; /* for recording thermal data to a file */
 49static int debug_on;
 50FILE *tmon_log;
 51/*cooling device used for the PID controller */
 52char ctrl_cdev[CDEV_NAME_SIZE] = "None";
 53int target_thermal_zone; /* user selected target zone instance */
 54static void	start_daemon_mode(void);
 55
 56pthread_t event_tid;
 57pthread_mutex_t input_lock;
 58void usage()
 59{
 60	printf("Usage: tmon [OPTION...]\n");
 61	printf("  -c, --control         cooling device in control\n");
 62	printf("  -d, --daemon          run as daemon, no TUI\n");
 63	printf("  -g, --debug           debug message in syslog\n");
 64	printf("  -h, --help            show this help message\n");
 65	printf("  -l, --log             log data to /var/tmp/tmon.log\n");
 66	printf("  -t, --time-interval   sampling time interval, > 1 sec.\n");
 67	printf("  -T, --target-temp     initial target temperature\n");
 68	printf("  -v, --version         show version\n");
 69	printf("  -z, --zone            target thermal zone id\n");
 70
 71	exit(0);
 72}
 73
 74void version()
 75{
 76	printf("TMON version %s\n", VERSION);
 77	exit(EXIT_SUCCESS);
 78}
 79
 80static void tmon_cleanup(void)
 81{
 82
 83	syslog(LOG_INFO, "TMON exit cleanup\n");
 84	fflush(stdout);
 85	refresh();
 86	if (tmon_log)
 87		fclose(tmon_log);
 88	if (event_tid) {
 89		pthread_mutex_lock(&input_lock);
 90		pthread_cancel(event_tid);
 91		pthread_mutex_unlock(&input_lock);
 92		pthread_mutex_destroy(&input_lock);
 93	}
 94	closelog();
 95	/* relax control knobs, undo throttling */
 96	set_ctrl_state(0);
 97
 98	keypad(stdscr, FALSE);
 99	echo();
100	nocbreak();
101	close_windows();
102	endwin();
103	free_thermal_data();
104
105	exit(1);
106}
107
108
109static void tmon_sig_handler(int sig)
110{
111	syslog(LOG_INFO, "TMON caught signal %d\n", sig);
112	refresh();
113	switch (sig) {
114	case SIGTERM:
115		printf("sigterm, exit and clean up\n");
116		fflush(stdout);
117		break;
118	case SIGKILL:
119		printf("sigkill, exit and clean up\n");
120		fflush(stdout);
121		break;
122	case SIGINT:
123		printf("ctrl-c, exit and clean up\n");
124		fflush(stdout);
125		break;
126	default:
127		break;
128	}
129	tmon_exit = true;
130}
131
132
133static void start_syslog(void)
134{
135	if (debug_on)
136		setlogmask(LOG_UPTO(LOG_DEBUG));
137	else
138		setlogmask(LOG_UPTO(LOG_ERR));
139	openlog("tmon.log", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
140	syslog(LOG_NOTICE, "TMON started by User %d", getuid());
141}
142
143static void prepare_logging(void)
144{
145	int i;
146	struct stat logstat;
147
148	if (!logging)
149		return;
150	/* open local data log file */
151	tmon_log = fopen(TMON_LOG_FILE, "w+");
152	if (!tmon_log) {
153		syslog(LOG_ERR, "failed to open log file %s\n", TMON_LOG_FILE);
154		return;
155	}
156
157	if (lstat(TMON_LOG_FILE, &logstat) < 0) {
158		syslog(LOG_ERR, "Unable to stat log file %s\n", TMON_LOG_FILE);
159		fclose(tmon_log);
160		tmon_log = NULL;
161		return;
162	}
163
164	/* The log file must be a regular file owned by us */
165	if (S_ISLNK(logstat.st_mode)) {
166		syslog(LOG_ERR, "Log file is a symlink.  Will not log\n");
167		fclose(tmon_log);
168		tmon_log = NULL;
169		return;
170	}
171
172	if (logstat.st_uid != getuid()) {
173		syslog(LOG_ERR, "We don't own the log file.  Not logging\n");
174		fclose(tmon_log);
175		tmon_log = NULL;
176		return;
177	}
178
179
180	fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n");
181	for (i = 0; i < ptdata.nr_tz_sensor; i++) {
182		char binding_str[33]; /* size of long + 1 */
183		int j;
184
185		memset(binding_str, 0, sizeof(binding_str));
186		for (j = 0; j < 32; j++)
187			binding_str[j] = (ptdata.tzi[i].cdev_binding & 1<<j) ?
188				'1' : '0';
189
190		fprintf(tmon_log, "#thermal zone %s%02d cdevs binding: %32s\n",
191			ptdata.tzi[i].type,
192			ptdata.tzi[i].instance,
193			binding_str);
194		for (j = 0; j <	ptdata.tzi[i].nr_trip_pts; j++) {
195			fprintf(tmon_log, "#\tTP%02d type:%s, temp:%lu\n", j,
196				trip_type_name[ptdata.tzi[i].tp[j].type],
197				ptdata.tzi[i].tp[j].temp);
198		}
199
200	}
201
202	for (i = 0; i <	ptdata.nr_cooling_dev; i++)
203		fprintf(tmon_log, "#cooling devices%02d: %s\n",
204			i, ptdata.cdi[i].type);
205
206	fprintf(tmon_log, "#---------- THERMAL DATA LOG STARTED -----------\n");
207	fprintf(tmon_log, "Samples TargetTemp ");
208	for (i = 0; i < ptdata.nr_tz_sensor; i++) {
209		fprintf(tmon_log, "%s%d    ", ptdata.tzi[i].type,
210			ptdata.tzi[i].instance);
211	}
212	for (i = 0; i <	ptdata.nr_cooling_dev; i++)
213		fprintf(tmon_log, "%s%d ", ptdata.cdi[i].type,
214			ptdata.cdi[i].instance);
215
216	fprintf(tmon_log, "\n");
217}
218
219static struct option opts[] = {
220	{ "control", 1, NULL, 'c' },
221	{ "daemon", 0, NULL, 'd' },
222	{ "time-interval", 1, NULL, 't' },
223	{ "target-temp", 1, NULL, 'T' },
224	{ "log", 0, NULL, 'l' },
225	{ "help", 0, NULL, 'h' },
226	{ "version", 0, NULL, 'v' },
227	{ "debug", 0, NULL, 'g' },
228	{ 0, 0, NULL, 0 }
229};
230
231
232int main(int argc, char **argv)
233{
234	int err = 0;
235	int id2 = 0, c;
236	double yk = 0.0, temp; /* controller output */
237	int target_tz_index;
238
239	if (geteuid() != 0) {
240		printf("TMON needs to be run as root\n");
241		exit(EXIT_FAILURE);
242	}
243
244	while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
245		switch (c) {
246		case 'c':
247			no_control = 0;
248			strncpy(ctrl_cdev, optarg, CDEV_NAME_SIZE);
249			break;
250		case 'd':
251			start_daemon_mode();
252			printf("Run TMON in daemon mode\n");
253			break;
254		case 't':
255			ticktime = strtod(optarg, NULL);
256			if (ticktime < 1)
257				ticktime = 1;
258			break;
259		case 'T':
260			temp = strtod(optarg, NULL);
261			if (temp < 0) {
262				fprintf(stderr, "error: temperature must be positive\n");
263				return 1;
264			}
265			target_temp_user = temp;
266			break;
267		case 'l':
268			printf("Logging data to /var/tmp/tmon.log\n");
269			logging = 1;
270			break;
271		case 'h':
272			usage();
273			break;
274		case 'v':
275			version();
276			break;
277		case 'g':
278			debug_on = 1;
279			break;
280		case 'z':
281			target_thermal_zone = strtod(optarg, NULL);
282			break;
283		default:
284			break;
285		}
286	}
287	if (pthread_mutex_init(&input_lock, NULL) != 0) {
288		fprintf(stderr, "\n mutex init failed, exit\n");
289		return 1;
290	}
291	start_syslog();
292	if (signal(SIGINT, tmon_sig_handler) == SIG_ERR)
293		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
294	if (signal(SIGTERM, tmon_sig_handler) == SIG_ERR)
295		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
296
297	if (probe_thermal_sysfs()) {
298		pthread_mutex_destroy(&input_lock);
299		closelog();
300		return -1;
301	}
302	initialize_curses();
303	setup_windows();
304	signal(SIGWINCH, resize_handler);
305	show_title_bar();
306	show_sensors_w();
307	show_cooling_device();
308	update_thermal_data();
309	show_data_w();
310	prepare_logging();
311	init_thermal_controller();
312
313	nodelay(stdscr, TRUE);
314	err = pthread_create(&event_tid, NULL, &handle_tui_events, NULL);
315	if (err != 0) {
316		printf("\ncan't create thread :[%s]", strerror(err));
317		tmon_cleanup();
318		exit(EXIT_FAILURE);
319	}
320
321	/* validate range of user selected target zone, default to the first
322	 * instance if out of range
323	 */
324	target_tz_index = zone_instance_to_index(target_thermal_zone);
325	if (target_tz_index < 0) {
326		target_thermal_zone = ptdata.tzi[0].instance;
327		syslog(LOG_ERR, "target zone is not found, default to %d\n",
328			target_thermal_zone);
329	}
330	while (1) {
331		sleep(ticktime);
332		show_title_bar();
333		show_sensors_w();
334		update_thermal_data();
335		if (!dialogue_on) {
336			show_data_w();
337			show_cooling_device();
338		}
339		cur_thermal_record++;
340		time_elapsed += ticktime;
341		controller_handler(trec[0].temp[target_tz_index] / 1000,
342				&yk);
343		trec[0].pid_out_pct = yk;
344		if (!dialogue_on)
345			show_control_w();
346		if (tmon_exit)
347			break;
348	}
349	tmon_cleanup();
350	return 0;
351}
352
353static void start_daemon_mode()
354{
355	daemon_mode = 1;
356	/* fork */
357	pid_t	sid, pid = fork();
358	if (pid < 0) {
 
359		exit(EXIT_FAILURE);
360	} else if (pid > 0)
361		/* kill parent */
362		exit(EXIT_SUCCESS);
363
364	/* disable TUI, it may not be necessary, but saves some resource */
365	disable_tui();
366
367	/* change the file mode mask */
368	umask(S_IWGRP | S_IWOTH);
369
370	/* new SID for the daemon process */
371	sid = setsid();
372	if (sid < 0)
373		exit(EXIT_FAILURE);
374
375	/* change working directory */
376	if ((chdir("/")) < 0)
377		exit(EXIT_FAILURE);
378
379
380	sleep(10);
381
382	close(STDIN_FILENO);
383	close(STDOUT_FILENO);
384	close(STDERR_FILENO);
385
386}