mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-14 00:24:05 +00:00
use pid_t instead of long for pid variables. #7099 (casper)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@25488 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
12
asterisk.c
12
asterisk.c
@@ -171,7 +171,7 @@ char debug_filename[AST_FILENAME_MAX] = "";
|
|||||||
|
|
||||||
static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */
|
static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */
|
||||||
static int ast_consock = -1; /*!< UNIX Socket for controlling another asterisk */
|
static int ast_consock = -1; /*!< UNIX Socket for controlling another asterisk */
|
||||||
int ast_mainpid;
|
pid_t ast_mainpid;
|
||||||
struct console {
|
struct console {
|
||||||
int fd; /*!< File descriptor */
|
int fd; /*!< File descriptor */
|
||||||
int p[2]; /*!< Pipe */
|
int p[2]; /*!< Pipe */
|
||||||
@@ -722,7 +722,7 @@ static void *netconsole(void *vconsole)
|
|||||||
|
|
||||||
if (gethostname(hostname, sizeof(hostname)-1))
|
if (gethostname(hostname, sizeof(hostname)-1))
|
||||||
ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
|
ast_copy_string(hostname, "<Unknown>", sizeof(hostname));
|
||||||
snprintf(tmp, sizeof(tmp), "%s/%d/%s\n", hostname, ast_mainpid, ASTERISK_VERSION);
|
snprintf(tmp, sizeof(tmp), "%s/%ld/%s\n", hostname, (long)ast_mainpid, ASTERISK_VERSION);
|
||||||
fdprint(con->fd, tmp);
|
fdprint(con->fd, tmp);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
fds[0].fd = con->fd;
|
fds[0].fd = con->fd;
|
||||||
@@ -2514,22 +2514,22 @@ int main(int argc, char *argv[])
|
|||||||
unlink(ast_config_AST_PID);
|
unlink(ast_config_AST_PID);
|
||||||
f = fopen(ast_config_AST_PID, "w");
|
f = fopen(ast_config_AST_PID, "w");
|
||||||
if (f) {
|
if (f) {
|
||||||
fprintf(f, "%d\n", (int)getpid());
|
fprintf(f, "%ld\n", (long)getpid());
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
||||||
|
|
||||||
if (ast_opt_always_fork || !ast_opt_no_fork) {
|
if (ast_opt_always_fork || !ast_opt_no_fork) {
|
||||||
daemon(0, 0);
|
daemon(0, 0);
|
||||||
|
ast_mainpid = getpid();
|
||||||
/* Blindly re-write pid file since we are forking */
|
/* Blindly re-write pid file since we are forking */
|
||||||
unlink(ast_config_AST_PID);
|
unlink(ast_config_AST_PID);
|
||||||
f = fopen(ast_config_AST_PID, "w");
|
f = fopen(ast_config_AST_PID, "w");
|
||||||
if (f) {
|
if (f) {
|
||||||
fprintf(f, "%d\n", (int)getpid());
|
fprintf(f, "%ld\n", (long)ast_mainpid);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else
|
} else
|
||||||
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
|
||||||
ast_mainpid = getpid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Test recursive mutex locking. */
|
/* Test recursive mutex locking. */
|
||||||
@@ -2656,7 +2656,7 @@ int main(int argc, char *argv[])
|
|||||||
/* Register our quit function */
|
/* Register our quit function */
|
||||||
char title[256];
|
char title[256];
|
||||||
set_icon("Asterisk");
|
set_icon("Asterisk");
|
||||||
snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %d)", hostname, ast_mainpid);
|
snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %ld)", hostname, (long)ast_mainpid);
|
||||||
set_title(title);
|
set_title(title);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@@ -114,7 +114,7 @@ extern char defaultlanguage[];
|
|||||||
|
|
||||||
extern time_t ast_startuptime;
|
extern time_t ast_startuptime;
|
||||||
extern time_t ast_lastreloadtime;
|
extern time_t ast_lastreloadtime;
|
||||||
extern int ast_mainpid;
|
extern pid_t ast_mainpid;
|
||||||
|
|
||||||
extern char record_cache_dir[AST_CACHE_DIR_LEN];
|
extern char record_cache_dir[AST_CACHE_DIR_LEN];
|
||||||
extern char debug_filename[AST_FILENAME_MAX];
|
extern char debug_filename[AST_FILENAME_MAX];
|
||||||
|
2
logger.c
2
logger.c
@@ -722,7 +722,7 @@ void ast_log(int level, const char *file, int line, const char *function, const
|
|||||||
if (logfiles.event_log && level == __LOG_EVENT) {
|
if (logfiles.event_log && level == __LOG_EVENT) {
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
fprintf(eventlog, "%s asterisk[%d]: ", date, getpid());
|
fprintf(eventlog, "%s asterisk[%ld]: ", date, (long)getpid());
|
||||||
vfprintf(eventlog, fmt, ap);
|
vfprintf(eventlog, fmt, ap);
|
||||||
fflush(eventlog);
|
fflush(eventlog);
|
||||||
|
|
||||||
|
@@ -66,7 +66,7 @@ struct outgoing {
|
|||||||
/* How long to wait for an answer */
|
/* How long to wait for an answer */
|
||||||
int waittime;
|
int waittime;
|
||||||
/* PID which is currently calling */
|
/* PID which is currently calling */
|
||||||
int callingpid;
|
long callingpid;
|
||||||
|
|
||||||
/* What to connect to outgoing */
|
/* What to connect to outgoing */
|
||||||
char tech[256];
|
char tech[256];
|
||||||
@@ -193,7 +193,7 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
|
|||||||
} else if (!strcasecmp(buf, "retry")) {
|
} else if (!strcasecmp(buf, "retry")) {
|
||||||
o->retries++;
|
o->retries++;
|
||||||
} else if (!strcasecmp(buf, "startretry")) {
|
} else if (!strcasecmp(buf, "startretry")) {
|
||||||
if (sscanf(c, "%d", &o->callingpid) != 1) {
|
if (sscanf(c, "%ld", &o->callingpid) != 1) {
|
||||||
ast_log(LOG_WARNING, "Unable to retrieve calling PID!\n");
|
ast_log(LOG_WARNING, "Unable to retrieve calling PID!\n");
|
||||||
o->callingpid = 0;
|
o->callingpid = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user