Date: Mon, 5 Jan 2009 15:12:12 +0000 (UTC) From: Tom Marchand <m0rchand@comcast.net> To: freebsd-questions@freebsd.org Subject: Re: why printf() don't work? Message-ID: <104871889.2409471231168332182.JavaMail.root@sz0104a.westchester.pa.mail.comcast.net> In-Reply-To: <022201c96f07$553b65a0$3f83a8c0@user863c0bf569>
next in thread | previous in thread | raw e-mail | index | archive | help
trying putting newlines in the strings like this:=20 =C2=A0 =C2=A0"receive overflow\n"=20 ----- Original Message -----=20 From: "Edward King" <zhangsc@neusoft.com>=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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?104871889.2409471231168332182.JavaMail.root>