static int controlPort = -1;
static int statPort = -1;
-static FILE *cfile;
-static FILE *ofile;
-static FILE *sfile;
+static FILE *ctrl_file_in = NULL;
+static FILE *data_file_out = NULL;
+static FILE *stat_file_out = NULL;
static struct option long_options[] = {
{"appid", required_argument, 0, 'a'},
}
static void openFileProcess();
-static FILE *tf;
+static FILE *pipef;
static void *output_thread(void *arg)
{
openFileProcess();
int linesRead = 0;
- while (getline(&buffer, &lsize, tf) != -1) {
- fputs(buffer, ofile);
+ while (getline(&buffer, &lsize, pipef) != -1) {
+ fputs(buffer, data_file_out);
++linesRead;
}
free(buffer);
tcsetattr(0,TCSANOW, &sterm);
}
#endif /* TIZEN */
- if (tf != NULL) {
- fclose(tf);
+ if (pipef != NULL) {
+ fclose(pipef);
if (isPipeOwner) {
unlink(pname);
}
}
- fflush(ofile);
+ fflush(data_file_out);
log_error("=== finished ===");
kill(getpid(), SIGKILL);
}
static void split(char *line, char **array, int n)
{
int i;
-
for (i = 0; i < n; i++) {
while(line[0] == ' ') *line++ = 0;
array[i] = line;
ncpu = ncpu - tmp + 1;
long psize = sysconf(_SC_PAGESIZE);
- fprintf(sfile, "psize %ld ncpu %d\n", psize, ncpu);
+ fprintf(stat_file_out, "psize %ld ncpu %d\n", psize, ncpu);
FILE *memf = fopen("/proc/meminfo", "r");
if (memf == NULL ) {
? (fstat.f_bsize / 1024) * fstat.f_bavail
: fstat.f_bavail / (1024 / fstat.f_bsize);
- fprintf(sfile,
+ fprintf(stat_file_out,
"%ld.%03d" " %s %s %s" " %s %s" " %s %s %ld %ld\n",
t, millisec,
stats[1], stats[3], stats[4], /* user system idle */
pstats[14 - 1], pstats[15 - 1], /* puser psystem */
mt[1], mf[1], available, pages * psize);
- fflush(sfile);
+ fflush(stat_file_out);
usleep(timeoutMicrosec);
}
static void openFileProcess()
{
if (ename == NULL) {
- tf = fopen(pname, "r");
- if (tf == NULL) {
+ pipef = fopen(pname, "r");
+ if (pipef == NULL) {
log_system_error_and_exit("fopen");
}
return;
log_error("PARENT close(%d)", id);
}
- tf = fdopen(pipefd[0], "r");
- if (tf == NULL) {
+ pipef = fdopen(pipefd[0], "r");
+ if (pipef == NULL) {
log_system_error_and_exit("fopen");
}
if (verbose) {
char *line = NULL;
ssize_t len = 0;
- cfile = stdin;
- ofile = stdout;
- sfile = stdout;
+ ctrl_file_in = stdin;
+ data_file_out = stdout;
+ stat_file_out = stdout;
while(!process_option(argc, argv));
if (controlPort > 0) {
int s = openPort(controlPort);
- cfile = fdopen(s, "r");
- if (cfile == NULL) {
+ ctrl_file_in = fdopen(s, "r");
+ if (ctrl_file_in == NULL) {
log_system_error_and_exit("fdopen(control,r)");
}
}
if (doinfo && (statPort > 0)) {
int s = openPort(statPort);
- sfile = fdopen(s, "w");
- if (sfile == NULL) {
+ stat_file_out = fdopen(s, "w");
+ if (stat_file_out == NULL) {
log_system_error_and_exit("fdopen(stat,w)");
}
}
#endif /* TIZEN */
/* Read command loop */
- while((len = getline(&line, &len, cfile)) != -1) {
+ while((len = getline(&line, &len, ctrl_file_in)) != -1) {
if (verbose) {
if ((len > 0) && (line[len - 1] == '\n')) {
line[len - 1] = 0;
SimpleThread(&outstat);
}
}
- }
+ } // while
return 0;
}