return 0;
}
-#ifdef HAVE_WIN32_PROC
-static BOOL WINAPI ctrlc_handler(DWORD type)
-{
- exit(STATUS_CONTROL_C_EXIT);
- return TRUE;
-}
-#endif
-
static void sdb_cleanup(void)
{
clear_sdbd_commandline_args(&sdbd_commandline_args);
unload_sdbd_plugin();
}
-void start_logging(void)
-{
-#ifdef HAVE_WIN32_PROC
- char temp[ MAX_PATH ];
- FILE* fnul;
- FILE* flog;
-
- GetTempPath( sizeof(temp) - 8, temp );
- strcat( temp, "sdb.log" );
-
- /* Win32 specific redirections */
- fnul = fopen( "NUL", "rt" );
- if (fnul != NULL)
- stdin[0] = fnul[0];
-
- flog = fopen( temp, "at" );
- if (flog == NULL)
- flog = fnul;
-
- setvbuf( flog, NULL, _IONBF, 0 );
-
- stdout[0] = flog[0];
- stderr[0] = flog[0];
- fprintf(stderr,"--- sdb starting (pid %d) ---\n", getpid());
-#else
- int fd;
-
- fd = unix_open("/dev/null", O_RDONLY);
- if (fd < 0) {
- // hopefully not gonna happen
- return;
- }
- dup2(fd, 0);
- sdb_close(fd);
-
- fd = unix_open("/tmp/sdb.log", O_WRONLY | O_CREAT | O_APPEND, 0640);
- if(fd < 0) {
- fd = unix_open("/dev/null", O_WRONLY);
- if (fd < 0) {
- // hopefully not gonna happen
- return;
- }
- }
- dup2(fd, 1);
- dup2(fd, 2);
- sdb_close(fd);
- fprintf(stderr,"--- sdb starting (pid %d) ---\n", getpid());
-#endif
-}
-
void start_device_log(void)
{
int fd;
sdb_mutex_unlock(&D_lock);
}
-int sdb_main(int is_daemon, int server_port)
+int sdb_main(int server_port)
{
check_emulator_or_device();
pthread_atfork(fork_prepare_handler, fork_parent_handler, fork_child_handler);
atexit(sdb_cleanup);
-#ifdef HAVE_WIN32_PROC
- SetConsoleCtrlHandler( ctrlc_handler, TRUE );
-#elif defined(HAVE_FORKEXEC)
+#if defined(HAVE_FORKEXEC)
// No SIGCHLD. Let the service subproc handle its children.
signal(SIGPIPE, SIG_IGN);
#endif
D("sdb_main(): post init_jdwp()\n");
#endif
- if (is_daemon)
- {
- // inform our parent that we are up and running.
-#ifdef HAVE_WIN32_PROC
- DWORD count;
- WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), "OK\n", 3, &count, NULL );
-#elif defined(HAVE_FORKEXEC)
- fprintf(stderr, "OK\n");
-#endif
- start_logging();
- }
-
D("Event loop starting\n");
fdevent_loop();
//sdbd will never die on emulator!
signal(SIGTERM, handle_sig_term); /* tizen specific */
- return sdb_main(0, DEFAULT_SDB_PORT);
+ return sdb_main(DEFAULT_SDB_PORT);
}
#include <sys/socket.h>
#endif
-#define ANDROID_SOCKET_ENV_PREFIX "ANDROID_SOCKET_"
-#define ANDROID_SOCKET_DIR "/dev/socket"
-
#ifdef __cplusplus
extern "C" {
#endif
/*
- * android_get_control_socket - simple helper function to get the file
- * descriptor of our init-managed Unix domain socket. `name' is the name of the
- * socket, as given in init.rc. Returns -1 on error.
- *
- * This is inline and not in libcutils proper because we want to use this in
- * third-party daemons with minimal modification.
- */
-static inline int android_get_control_socket(const char *name)
-{
- char key[64] = ANDROID_SOCKET_ENV_PREFIX;
- const char *val;
- int fd;
-
- /* build our environment variable, counting cycles like a wolf ... */
-#if HAVE_STRLCPY
- strlcpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
- name,
- sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
-#else /* for the host, which may lack the almightly strncpy ... */
- strncpy(key + sizeof(ANDROID_SOCKET_ENV_PREFIX) - 1,
- name,
- sizeof(key) - sizeof(ANDROID_SOCKET_ENV_PREFIX));
- key[sizeof(key)-1] = '\0';
-#endif
-
- val = getenv(key);
- if (!val)
- return -1;
-
- errno = 0;
- fd = strtol(val, NULL, 10);
- if (errno)
- return -1;
-
- return fd;
-}
-
-/*
* See also android.os.LocalSocketAddress.Namespace
*/
// Linux "abstract" (non-filesystem) namespace