From owner-freebsd-questions@FreeBSD.ORG Mon Jan 5 15:12:12 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EAFD1065672 for ; Mon, 5 Jan 2009 15:12:12 +0000 (UTC) (envelope-from m0rchand@comcast.net) Received: from QMTA03.westchester.pa.mail.comcast.net (qmta03.westchester.pa.mail.comcast.net [76.96.62.32]) by mx1.freebsd.org (Postfix) with ESMTP id 186538FC1A for ; Mon, 5 Jan 2009 15:12:11 +0000 (UTC) (envelope-from m0rchand@comcast.net) Received: from OMTA08.westchester.pa.mail.comcast.net ([76.96.62.12]) by QMTA03.westchester.pa.mail.comcast.net with comcast id zn691a00A0Fqzac53rCC6B; Mon, 05 Jan 2009 15:12:12 +0000 Received: from sz0104.wc.mail.comcast.net ([76.96.58.164]) by OMTA08.westchester.pa.mail.comcast.net with comcast id zrCA1a01D3Yby643UrCAJr; Mon, 05 Jan 2009 15:12:10 +0000 Date: Mon, 5 Jan 2009 15:12:12 +0000 (UTC) From: Tom Marchand To: freebsd-questions@freebsd.org Message-ID: <104871889.2409471231168332182.JavaMail.root@sz0104a.westchester.pa.mail.comcast.net> In-Reply-To: <022201c96f07$553b65a0$3f83a8c0@user863c0bf569> MIME-Version: 1.0 X-Originating-IP: [157.174.221.167] X-Mailer: Zimbra 5.0.9_GA_2533.RHEL5_64 (ZimbraWebClient - IE6 (Win)/5.0.9_GA_2533.RHEL5_64) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: why printf() don't work? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jan 2009 15:12:12 -0000 trying putting newlines in the strings like this:=20 =C2=A0 =C2=A0"receive overflow\n"=20 ----- Original Message -----=20 From: "Edward King" =20 To: freebsd-questions@freebsd.org=20 Sent: Monday, January 5, 2009 2:29:23 AM GMT -05:00 US/Canada Eastern=20 Subject: why printf() don't work?=20 I use FreeBSD7.0,and use signal,like follows: signal(SIGHUP,sig_hup); signa= l(SIGIO,sig_io); when I run call following code,it can run,but I find a puz= zled question,it should print some information,such as printf("execute main= ()") will print execute main(),but in fact,printf fuction print none!!! Why= printf function do not go work? my code is follows: #include "sys/ioctl.h"= #include "unp.h" static int sockfd; #define QSIZE 8 #define MAXDG 4096 typ= edef struct{ void *dg_data; size_t dg_len; struct sockaddr *dg_sa; socklen_= t dg_salen; }DG; static DG dg[QSIZE]; static long cntread[QSIZE+1]; static = int iget; static int iput; static int nqueue; static socklen_t clilen; stat= ic void sig_io(int); static void sig_hup(int); int main(int argc,char **arg= v){ printf("execute main()"); int sockfd; struct sockaddr_in servaddr,cliad= dr; sockfd=3Dsocket(AF_INET,SOCK_DGRAM,0); bzero(&servaddr,sizeof(servaddr)= ); servaddr.sin_family=3DAF_INET; servaddr.sin_addr.s_addr=3Dhtonl(INADDR_A= NY); servaddr.sin_port=3Dhtons(SERV_PORT); bind(sockfd,(SA *)&servaddr,size= of(servaddr)); dg_echo(sockfd,(SA *)&cliaddr,sizeof(cliaddr)); } void dg_ec= ho(int sockfd_arg,SA *pcliaddr,socklen_t clilen_arg){ printf("called dg_ech= o"); int i; const int on=3D1; sigset_t zeromask,newmask,oldmask; sockfd=3Ds= ockfd_arg; clilen=3Dclilen_arg; for(i=3D0;i =3DQSIZE) iget=3D0; sigprocmask= (SIG_BLOCK,&newmask,&oldmask); nqueue--; } } static void sig_io(int signo){= printf("sig_io called"); ssize_t len; int nread; DG *ptr; for(nread=3D0;;)= { if(nqueue>=3DQSIZE) err_quit("receive overflow"); ptr=3D&dg[iput]; ptr->d= g_salen=3Dclilen; len=3Drecvfrom(sockfd,ptr->dg_data,MAXDG,0,ptr->dg_sa,&pt= r->dg_salen); if(len<0){ if(errno=3D=3DEWOULDBLOCK) break; else err_sys("re= cvfrom error"); } ptr->dg_len=3Dlen; nread++; nqueue++; if(++iput>=3DQSIZE)= iput=3D0; } cntread[nread]++; } static void sig_hup(int signo){ printf("si= g_hup called"); int i; for(i=3D0;i<=3DQSIZE;i++) printf("cntread[%d]=3D%ld\= n",i,cntread[i]); } -------------------------------------------------------= -------------------------------------------- Confidentiality Notice: The in= formation contained in this e-mail and any accompanying attachment(s) is in= tended only for the use of the intended recipient and may be confidential a= nd/or privileged of Neusoft Corporation, its subsidiaries and/or its affili= ates. If any reader of this communication is not the intended recipient, un= authorized use, forwarding, printing, storing, disclosure or copying is str= ictly prohibited, and may be unlawful.If you have received this communicati= on in error,please immediately notify the sender by return e-mail, and dele= te the original message and all copies from your system. Thank you. -------= ---------------------------------------------------------------------------= -----------------=20 _______________________________________________ freebsd-questions@freebsd.o= rg mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions= To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.or= g"