<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: getc() trap into infinite-loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620570#M726178</link>
    <description>No, please notice, while loop has been commented in source, and infiniteloop occurs in FIRST getc() function, and it obviously related with source encoding because it works well when encoding is shift-jis.&lt;BR /&gt;</description>
    <pubDate>Tue, 27 Nov 2001 09:27:28 GMT</pubDate>
    <dc:creator>forcerick</dc:creator>
    <dc:date>2001-11-27T09:27:28Z</dc:date>
    <item>
      <title>getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620568#M726176</link>
      <description>Hi, All&lt;BR /&gt;&lt;BR /&gt;The following source is euc_jp encoding,&lt;BR /&gt;aCC compiling, running result just output &lt;BR /&gt;"1" string, and it doesn't seem to jump out &lt;BR /&gt;of the first function getc(), and program &lt;BR /&gt;trap into infinite-loop, cannot exit. but &lt;BR /&gt;if changing source's encoding to shift-jis, &lt;BR /&gt;it works well. &lt;BR /&gt;How to fix this? Thanks a lot. &lt;BR /&gt;OS: HP-UX 11.0  LANG: euc_jp with JSE support&lt;BR /&gt;NOTICE: remote shell xsh's input parameter is&lt;BR /&gt;necessary for test&lt;BR /&gt;&lt;BR /&gt;====================gdb info==================&lt;BR /&gt;(gdb) n&lt;BR /&gt;Single stepping until exit from function getc,&lt;BR /&gt;which has no line number information.&lt;BR /&gt;0x77c37650 in _nss_files_read_line () from /usr/lib/libnss_files.1&lt;BR /&gt;(gdb) n&lt;BR /&gt;Single stepping until exit from function _nss_files_read_line,&lt;BR /&gt;which has no line number information.&lt;BR /&gt;&lt;BR /&gt;Breakpoint 1, 0x77fa1ff8 in getc () from /usr/lib/libc.2&lt;BR /&gt;(gdb) n&lt;BR /&gt;Single stepping until exit from function getc,&lt;BR /&gt;which has no line number information.&lt;BR /&gt;0x77c37650 in _nss_files_read_line () from /usr/lib/libnss_files.1&lt;BR /&gt;(gdb) n&lt;BR /&gt;Single stepping until exit from function _nss_files_read_line,&lt;BR /&gt;which has no line number information.&lt;BR /&gt;&lt;BR /&gt;Breakpoint 1, 0x77fa1ff8 in getc () from /usr/lib/libc.2&lt;BR /&gt;(gdb) &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;***********************************************&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;NETINET&gt;&lt;BR /&gt;#include &lt;NETDB.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;char *host[] = { "192.168.3.61" };&lt;BR /&gt;char *user = "gyomu";&lt;BR /&gt;char *passwd = "gyomu";&lt;BR /&gt;char *cmd = "/export/disk1/p2/gyomu/jwu/rexec/xsh ??????????????????1??????";&lt;BR /&gt;&lt;BR /&gt;main(int argc, char **argv)&lt;BR /&gt;{&lt;BR /&gt;    int sd;&lt;BR /&gt;    int n=0;&lt;BR /&gt;    FILE *fp;&lt;BR /&gt;    char ch;&lt;BR /&gt; char sBuf[1024];&lt;BR /&gt;    struct servent *servent;&lt;BR /&gt;&lt;BR /&gt;    servent = getservbyname("exec", "tcp");&lt;BR /&gt;    sd = rexec(host, servent-&amp;gt;s_port, user, passwd, cmd, 0);&lt;BR /&gt;    fp = fdopen(sd, "r");&lt;BR /&gt;printf("1\n");  &lt;BR /&gt;    getc(fp);&lt;BR /&gt;printf("2\n");  &lt;BR /&gt;    getc(fp);&lt;BR /&gt;printf("3\n");  &lt;BR /&gt;    getc(fp);&lt;BR /&gt;printf("4\n");  &lt;BR /&gt;&lt;BR /&gt;//  while ((ch = getc(fp)) != EOF) {&lt;BR /&gt;//     putchar(ch);&lt;BR /&gt;// }&lt;BR /&gt;}&lt;/STDIO.H&gt;&lt;/NETDB.H&gt;&lt;/NETINET&gt;&lt;/SYS&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
      <pubDate>Tue, 27 Nov 2001 08:14:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620568#M726176</guid>
      <dc:creator>forcerick</dc:creator>
      <dc:date>2001-11-27T08:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620569#M726177</link>
      <description>Read this extract from man getc:  &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  getc() and getchar() are implemented both as library functions and                                                            &lt;BR /&gt;      macros.  The macro versions, which are used by default, are defined in                                                        &lt;BR /&gt;      &lt;STDIO.H&gt;.  To obtain the library function either use a #undef to                                                             &lt;BR /&gt;      remove the macro definition or, if compiling in ANSI-C mode, enclose                                                          &lt;BR /&gt;      the function name in parenthesis or use the function address.  The                                                            &lt;BR /&gt;      following example illustrates each of these methods :                                                                         &lt;BR /&gt;                                                                                                                                    &lt;BR /&gt;           #include &lt;STDIO.H&gt;                                                                                                       &lt;BR /&gt;           #undef getc                                                                                                              &lt;BR /&gt;               ...                                                                                                                  &lt;BR /&gt;           main()                                                                                                                   &lt;BR /&gt;           {                                                                                                                        &lt;BR /&gt;               int (*get_char()) ();                                                                                                &lt;BR /&gt;               ...                                                                                                                  &lt;BR /&gt;               return_val=getc(c,fd);                                                                                               &lt;BR /&gt;               ...                                                                                                                  &lt;BR /&gt;               return_val=(getc)(c,fd1);                                                                                            &lt;BR /&gt;               ...                                                                                                                  &lt;BR /&gt;               get_char = getchar;                                                                                                  &lt;BR /&gt;           };                                                                                                                       &lt;BR /&gt;                                                                                                                                    &lt;BR /&gt;      If the integer value returned by getc(), getc_unlocked(), getchar(),                                                          &lt;BR /&gt;      getchar_unlocked(), or fgetc() is stored into a character variable                                                            &lt;BR /&gt;      then compared against the integer constant EOF, the comparison may                                                            &lt;BR /&gt;      never succeed because sign-extension of a character on widening to                                                            &lt;BR /&gt;      integer is machine-dependent.                                                                                                 &lt;BR /&gt;&lt;BR /&gt;You are using char type.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/STDIO.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Tue, 27 Nov 2001 08:55:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620569#M726177</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-11-27T08:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620570#M726178</link>
      <description>No, please notice, while loop has been commented in source, and infiniteloop occurs in FIRST getc() function, and it obviously related with source encoding because it works well when encoding is shift-jis.&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Nov 2001 09:27:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620570#M726178</guid>
      <dc:creator>forcerick</dc:creator>
      <dc:date>2001-11-27T09:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620571#M726179</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Commenting in C is &lt;BR /&gt;/* to be commented include here */&lt;BR /&gt;&lt;BR /&gt;like this . in ur programe it // won't work.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Joe.</description>
      <pubDate>Tue, 27 Nov 2001 09:37:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620571#M726179</guid>
      <dc:creator>Joseph Chakkery</dc:creator>
      <dc:date>2001-11-27T09:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620572#M726180</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;while loop in ur program should be like following.&lt;BR /&gt;&lt;BR /&gt;/*  while ((ch = getc(fp)) != EOF) { &lt;BR /&gt;putchar(ch); &lt;BR /&gt;*/ &lt;BR /&gt;&lt;BR /&gt;Try this &lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Joe.&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Nov 2001 09:39:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620572#M726180</guid>
      <dc:creator>Joseph Chakkery</dc:creator>
      <dc:date>2001-11-27T09:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620573#M726181</link>
      <description>hi, I use aCC C++ compile, two comment methods are OKAY, it doesn't matter, the core problem is definiteloop in getc().</description>
      <pubDate>Tue, 27 Nov 2001 09:44:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620573#M726181</guid>
      <dc:creator>forcerick</dc:creator>
      <dc:date>2001-11-27T09:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620574#M726182</link>
      <description>Sorry forcerick I didn't notice that.&lt;BR /&gt;I thought it is in ANSI-C.&lt;BR /&gt;&lt;BR /&gt;Do u have fflush(stdin) in that. try giving this after getc() function.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Joe.</description>
      <pubDate>Tue, 27 Nov 2001 09:47:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620574#M726182</guid>
      <dc:creator>Joseph Chakkery</dc:creator>
      <dc:date>2001-11-27T09:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620575#M726183</link>
      <description>hi, infinite-loop occurs in the process of getc() function, neither before that nor after that</description>
      <pubDate>Tue, 27 Nov 2001 09:57:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620575#M726183</guid>
      <dc:creator>forcerick</dc:creator>
      <dc:date>2001-11-27T09:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: getc() trap into infinite-loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620576#M726184</link>
      <description>&lt;BR /&gt;Well.. check returns for gethostbyname, rexec and fdopen&lt;BR /&gt;&lt;BR /&gt;Good luck.</description>
      <pubDate>Tue, 27 Nov 2001 12:14:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/getc-trap-into-infinite-loop/m-p/2620576#M726184</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-11-27T12:14:41Z</dc:date>
    </item>
  </channel>
</rss>

