rpcdump: Don't call CSocket::connect() before setting up hooks

This commit is contained in:
Andreas Kling 2019-09-11 19:56:04 +02:00
parent 99970d7d4b
commit 8c8fecd6bf
Notes: sideshowbarker 2024-07-19 12:09:32 +09:00

View file

@ -1,6 +1,7 @@
#include <LibCore/CEventLoop.h>
#include <LibCore/CLocalSocket.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv)
{
@ -14,11 +15,6 @@ int main(int argc, char** argv)
int pid = atoi(argv[1]);
CLocalSocket socket;
auto success = socket.connect(CSocketAddress::local(String::format("/tmp/rpc.%d", pid)));
if (!success) {
fprintf(stderr, "Couldn't connect to PID %d\n", pid);
return 1;
}
socket.on_connected = [&] {
dbg() << "Connected to PID " << pid;
@ -38,5 +34,11 @@ int main(int argc, char** argv)
printf("\n");
};
auto success = socket.connect(CSocketAddress::local(String::format("/tmp/rpc.%d", pid)));
if (!success) {
fprintf(stderr, "Couldn't connect to PID %d\n", pid);
return 1;
}
return loop.exec();
}