From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=33881 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OO9Wb-00036P-HV for qemu-devel@nongnu.org; Mon, 14 Jun 2010 09:16:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OO9KF-0007hp-4a for qemu-devel@nongnu.org; Mon, 14 Jun 2010 09:03:40 -0400 Received: from eu1sys200aog118.obsmtp.com ([207.126.144.145]:33077) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OO9KE-0007hW-MU for qemu-devel@nongnu.org; Mon, 14 Jun 2010 09:03:39 -0400 Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 844B72A1 for ; Mon, 14 Jun 2010 13:03:27 +0000 (GMT) Received: from mail2.gnb.st.com (mail2.gnb.st.com [164.129.119.59]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4B23025B2 for ; Mon, 14 Jun 2010 13:03:27 +0000 (GMT) Message-ID: <4C16289D.8040708@st.com> Date: Mon, 14 Jun 2010 15:03:25 +0200 From: Christophe LYON MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] ARM/system mode/stdin List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Hello, I am trying to use qemu-system-arm (0.12.3) to execute an ARM bare machine program (not a Linux kernel), and I have some trouble when the program in question tries to read from stdin. The program does use ARM semihosting to communicate with the host. Here is the sample code: ====================== #include int main() { int i, j; char tab[81]; printf("enter a number\n"); scanf("%d", &i); printf("enter a string (max: 80 char)\n"); scanf("%80s", tab); printf("enter a number\n"); scanf("%d", &j); printf("You entered:\n%d\n%s\n%d\n", i, tab, j); return 0; } ======================= (compiled with arm-none-eabi-gcc -O0 -mcpu=cortex-a9) To execute it, I use: $ qemu-system-arm -semihosting -cpu cortex-a9 -nographic -kernel ./input.exe In this case, it does not wait for me to type something: enter a number enter a string (max: 80 char) enter a number You entered: 134217720 1 Now, if $ cat data 4 hello 5 $ qemu-system-arm -semihosting -cpu cortex-a9 -nographic -kernel ./input.exe < data enter a number enter a string (max: 80 char) enter a number You entered: 134217720 ello 5 as you can see, the first 3 chars of 'data' have been changed/swallowed. If I remove fcntl(0, F_SETFL, O_NONBLOCK); from term_init() (qemu-char.c), then I get expected behaviour when I don't redirect stdin, but this has no effect on the latter case. What should I do/patch to achieve the behaviour I'd like? Thanks! Christophe.