Skip to content

Commit

Permalink
Processing (Windows): generate unique pipe name
Browse files Browse the repository at this point in the history
Fix #1346
  • Loading branch information
CarterLi committed Oct 18, 2024
1 parent bd4bc87 commit 5497cb6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/common/processing_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
{
int timeout = instance.config.general.processingTimeout;

wchar_t pipeName[32];
swprintf(pipeName, sizeof(pipeName) / sizeof(*pipeName), L"\\\\.\\pipe\\FASTFETCH-%u", GetCurrentProcessId());

FF_AUTO_CLOSE_FD HANDLE hChildPipeRead = CreateNamedPipeW(
L"\\\\.\\pipe\\LOCAL\\",
pipeName,
PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE | (timeout < 0 ? 0 : FILE_FLAG_OVERLAPPED),
0,
1,
Expand All @@ -60,10 +63,10 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
NULL
);
if (hChildPipeRead == INVALID_HANDLE_VALUE)
return "CreateNamedPipeW(L\"\\\\.\\pipe\\LOCAL\\\") failed";
return "CreateNamedPipeW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed";

HANDLE hChildPipeWrite = CreateFileW(
L"\\\\.\\pipe\\LOCAL\\",
pipeName,
GENERIC_WRITE,
0,
&(SECURITY_ATTRIBUTES){
Expand All @@ -76,7 +79,7 @@ const char* ffProcessAppendOutput(FFstrbuf* buffer, char* const argv[], bool use
NULL
);
if (hChildPipeWrite == INVALID_HANDLE_VALUE)
return "CreateFileW(L\"\\\\.\\pipe\\LOCAL\\\") failed";
return "CreateFileW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed";

PROCESS_INFORMATION piProcInfo = {0};

Expand Down

0 comments on commit 5497cb6

Please sign in to comment.