index 48ef3d3e382de50975b5466095952325dda11543..a5c7e4c871c4b8fd10ef1e73d889a130ba84f54a 100644 (file)
/*
- * Copyright (c) 2012, Texas Instruments Incorporated
+ * Copyright (c) 2012-2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <ladclient.h>
#include <_lad.h>
-static Bool verbose = FALSE;
+
+/* traces in this file are controlled via _LAD_Client_verbose */
+Bool _LAD_Client_verbose = FALSE;
+#define verbose _LAD_Client_verbose
typedef struct _LAD_ClientInfo {
Bool connectedToLAD; /* connection status */
static LAD_Status initWrappers(Void);
static Bool openCommandFIFO(Void);
+
+#if defined(IPC_BUILDOS_ANDROID)
+static pthread_mutex_t modGate = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+#else
// only _NP (non-portable) type available in CG tools which we're using
static pthread_mutex_t modGate = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-// static pthread_mutex_t modGate = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+#endif
/*
double delta;
Int assignedId;
FILE * filePtr;
+ int flags;
Int n;
Int pid;
struct LAD_CommandObj cmd;
}
}
+ /* make sure FIFO fd doesn't exist for 'fork() -> exec*()'ed child */
+ flags = fcntl(fileno(filePtr), F_GETFD);
+ if (flags != -1) {
+ fcntl(fileno(filePtr), F_SETFD, flags | FD_CLOEXEC);
+ }
+
/* now get LAD's response to the connection request */
n = fread(&rsp, LAD_RESPONSELENGTH, 1, filePtr);
*/
static Bool openCommandFIFO(Void)
{
+ int flags;
+
/* open a file for writing to FIFO */
commandFIFOFilePtr = fopen(commandFIFOFileName, "w");
return(FALSE);
}
+ /* make sure FIFO fd doesn't exist for 'fork() -> exec*()'ed child */
+ flags = fcntl(fileno(commandFIFOFilePtr), F_GETFD);
+ if (flags != -1) {
+ fcntl(fileno(commandFIFOFilePtr), F_SETFD, flags | FD_CLOEXEC);
+ }
+
return(TRUE);
}