summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
blob: 126c85dfd7ec7f57a3bc7f47d0d478cc73372648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (C) 2016 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include <stdio.h>

int main(int, char **argv)
{
    const char *msg = argv[1];
    char buf[2];

    puts(msg);
    fflush(stdout);

    // wait for a newline
    const char *result = fgets(buf, sizeof buf, stdin);
    if (result != buf)
        return -1;

    puts(msg);
    fflush(stdout);
    return 0;
}