Skip to content

Commit aed531d

Browse files
committed
pcm-client: be more user-friendly and fix exit code
1 parent 47890b8 commit aed531d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/client/main.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,21 @@ void printTitle(std::string title)
1515
std::cout << std::setw(26) << std::left << title;
1616
}
1717

18-
int main(int /*argc*/, char *argv[])
18+
int main(int argc, char *argv[])
1919
{
20+
if (argc < 2)
21+
{
22+
std::cerr << "Usage: " << argv[0] << " pollMs\n";
23+
return -1;
24+
}
2025
PCMDaemon::Client client;
2126
// client.setSharedMemoryIdLocation("/tmp/test-file");
2227
client.connect();
2328
client.setPollInterval(atoi(argv[1]));
2429

2530
int coutPrecision = 2;
2631

27-
while(true)
32+
while (true)
2833
{
2934
PCMDaemon::SharedPCMState& state = client.read();
3035
PCMDaemon::SharedPCMCounters& counters = state.pcm;
@@ -379,5 +384,5 @@ int main(int /*argc*/, char *argv[])
379384
std::cout << std::flush;
380385
}
381386

382-
return 1;
387+
return 0;
383388
}

0 commit comments

Comments
 (0)