tools/drdeploy.c
/* i#200/PR 459481: communicate child pid via file */
i#200/PR 459481: communicate child pid via file
i#200 / PR 459481 : communicate child pid via file
static void
write_pid_to_file(const char *pidfile, process_id_t pid)
{
    HANDLE f = CreateFile(pidfile, GENERIC_WRITE, FILE_SHARE_READ,
                          NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
    if (f == INVALID_HANDLE_VALUE) {
        warn("cannot open %s: %d\n", pidfile, GetLastError());
    } else {
        TCHAR pidbuf[16];
        BOOL ok;
        DWORD written;
        _snprintf(pidbuf, BUFFER_SIZE_ELEMENTS(pidbuf), "%d\n", pid);
        NULL_TERMINATE_BUFFER(pidbuf);
        ok = WriteFile(f, pidbuf, (DWORD)strlen(pidbuf), &written, NULL);
        assert(ok && written == strlen(pidbuf));
        CloseHandle(f);
    }
}
static void write_pid_to_file ( const char * pidfile , process_id_t pid ) { HANDLE f = CreateFile ( pidfile , GENERIC_WRITE , FILE_SHARE_READ , NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ) ; if ( f == INVALID_HANDLE_VALUE ) { warn ( " \n " , pidfile , GetLastError ( ) ) ; } else { TCHAR pidbuf [ 16 ] ; BOOL ok ; DWORD written ; _snprintf ( pidbuf , BUFFER_SIZE_ELEMENTS ( pidbuf ) , " \n " , pid ) ; NULL_TERMINATE_BUFFER ( pidbuf ) ; ok = WriteFile ( f , pidbuf , ( DWORD ) strlen ( pidbuf ) , & written , NULL ) ; assert ( ok && written == strlen ( pidbuf ) ) ; CloseHandle ( f ) ; } }
i#200/PR 459481: communicate child pid via file
i#200 / PR 459481 : communicate child pid via file