This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Executable from x86_64-w64-mingw32-gcc.exe waits for input before prompt in Cygwin terminal but not Win Command Prompt
- From: Randy Decker <randydecker at earthlink dot net>
- To: Cygwin at cygwin dot com
- Date: Sat, 11 Apr 2015 20:15:33 -0400 (EDT)
- Subject: Executable from x86_64-w64-mingw32-gcc.exe waits for input before prompt in Cygwin terminal but not Win Command Prompt
- Authentication-results: sourceware.org; auth=none
- Reply-to: Randy Decker <randydecker at earthlink dot net>
# Brief problem description
# C source file - 'printf("Test");' added as diagnostics
# Source compiles and executes in Ubuntu
# Executable compiled in cygwin terminal OK in command prompt W8.1
# - Also OK in another machine running Windows 8.1
# Same executable in cygwin term waits for input before usage hint
FROM CYGWIN64 TERMINAL
Randy@Hartford ~
$ cat countbytes.c
/* This program counts the number of bytes in a C source file.
The program prompts the user for a file name and then concatenates
the ".c" extension to this name. It uses the function getc to read
the characters.
program from "Applications Programming in ANSI C" by
Hohnsonbaugh & Kalin
*/
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
main( )
{
FILE* fptr;
char extension[] = ".c";
int char_count;
printf("Test");
printf("\n\n\tFile name (NO extension):\t");
char file_name[FILENAME_MAX]; /* defined in stdio.h*/
scanf("%s",file_name);
strcat(file_name,extension);
fptr=fopen(file_name,"rb");
for(char_count=0; getc(fptr) !=EOF; ++char_count);
printf("\n\tByte size:\t%d", char_count);
printf("\n");
fclose(fptr);
return EXIT_SUCCESS;
}
# Confirm Countbytes.exe not yet here
Randy@Hartford ~
$ ls -a
. .swp myhello.exe
.$$$ countbytes.c myhello2.exe
.. countem.exe myhelloworld.c
.bash_history countem3.exe testc.c
.bash_profile countemm.exe testit.exe
.bash_profile_temp countemm2.exe testittestc.exe
.bash_profileWin.txt countOnUbuntu.txt testtext.txt
.bashrc cygwinResults.txt welcome.exe
.bashrc_ORG Hello.c x86_64-w64-mingw32-gcc.exe
.inputrc HelloFromUnix.c
.profile HelloFromUnix-PFEvsNotepad.c
# Show alias
Randy@Hartford ~
$ alias
alias gcc='C:/cygwin64/bin/x86_64-w64-mingw32-gcc.exe'
# Compile the program
Randy@Hartford ~
$ gcc -o countbytes countbytes.c
# Verify countbytes.exe now exists
Randy@Hartford ~
$ ls
countbytes.c cygwinResults.txt Progress_Notes.txt
->countbytes.exe Hello.c testc.c
countem.exe HelloFromUnix.c testit.exe
countem3.exe HelloFromUnix-PFEvsNotepad.c testittestc.exe
countemm.exe myhello.exe testtext.txt
countemm2.exe myhello2.exe welcome.exe
countOnUbuntu.txt myhelloworld.c x86_64-w64-mingw32-gcc.exe
# Execute the output in cygwin64 terminal. Program waits with no output
# Until enter is pressed on a non blank line.
Randy@Hartford ~
$ ./countbytes
countbytes
Test
File name (NO extension):
Byte size: 865
Randy@Hartford ~
# Demonstrate same files as Cygwin64 Terminal
FROM WINDOWS 8.1 COMMAND PROMPT
Directory of C:\cygwin64\home\Randy
[.] [..]
.$$$ .bashrc
.bashrc_ORG .bash_history
.bash_profile .bash_profileWin.txt
.bash_profile_temp .inputrc
.profile .swp
countbytes.c ->countbytes.exe
countem.exe countem3.exe
countemm.exe countemm2.exe
countOnUbuntu.txt cygwinResults.txt
Hello.c HelloFromUnix-PFEvsNotepad.c
HelloFromUnix.c myhello.exe
myhello2.exe myhelloworld.c
Progress_Notes.txt testc.c
testit.exe testittestc.exe
testtext.txt welcome.exe
x86_64-w64-mingw32-gcc.exe
31 File(s) 1,289,107 bytes
2 Dir(s) 142,941,614,080 bytes free
# Execute the output in Windows command prompt terminal.
# Program PRINTS " File name (NO extension):"
# then waits Until filename is entered.
# NOTE: Execution of same code in Ubuntu 14.4 works like this.
C:\cygwin64\home\Randy>countbytes
Test
File name (NO extension): countbytes
Byte size: 865
C:\cygwin64\home\Randy>
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple