This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: setvbuf / [ANNOUNCEMENT] Updated: cygwin-1.5.5-1


The attached test case does should display test2 wait
five seconds and then display test3, instead on my
system it issues test2 and test3 simultanuously.

Thanks,
jj
--- Christopher Faylor <cgf-rcm@cygwin.com> wrote:
> On Wed, Oct 01, 2003 at 10:49:08AM -0700, Jan Jaeger
> wrote:
> >I have downloaded the latest (I think?) version of
> cygwin, but my
> >problem still persists.  uname -a reports:
> CYGWIN_NT-5.1 jj
> >1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown
> unknown Cygwin.  The 0.94
> >does not look quite right to me is this correct? 
> If so, which ftp site
> >would contain a 1.xx?
> 
> setup.exe downloads the latest version of
> everything.  This is confirmed
> by the 1.5.5 in your version above.  Since I
> announced this new version
> 10+ days ago, it is a safe bet that all of the
> mirror sites listed by
> setup.exe have cygwin 1.5.5.
> 
> The test case that you previously provided works as
> expected.  If you
> are having other problems, you'll need to clarify
> them with a new test
> case.
> --
> Please use the resources at cygwin.com rather than
> sending personal email.
> Special for spam email harvesters: send email to
> aaaspam@sourceware.org
> and be permanently blocked from mailing lists at
sources.redhat.com


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <pthread.h>

static pthread_attr_t  logger_attr;
static pthread_cond_t  logger_cond;
static pthread_mutex_t  logger_lock;
static pthread_t   logger_tid;


static int pipefd[2];

void *logger_thread(void *arg)
{
int n;
char buffer[80];

  
  setvbuf(stdout, NULL, _IOLBF, 0); // *** THIS DOES NOT WORK PROPERLY ***

  pthread_mutex_lock(&logger_lock);
  pthread_cond_signal(&logger_cond);
  pthread_mutex_unlock(&logger_lock);

  while(1)
  {
    n = read(pipefd[0], buffer, sizeof(buffer));
    buffer[n] = '\0';
    fprintf(stderr,buffer);
  }
}

main()
{

  pipe(pipefd);
  dup2(pipefd[1],STDOUT_FILENO);

  pthread_attr_init(&logger_attr);
  pthread_attr_setstacksize(&logger_attr,1048576);
  pthread_attr_setdetachstate(&logger_attr,PTHREAD_CREATE_DETACHED);
  pthread_cond_init (&logger_cond,NULL);
  pthread_mutex_init (&logger_lock,NULL);
  pthread_create (&logger_tid, &logger_attr, logger_thread, NULL);
  pthread_mutex_lock(&logger_lock);
  pthread_cond_wait(&logger_cond,&logger_lock);
  pthread_mutex_unlock(&logger_lock);


//setvbuf(stdout, NULL, _IOLBF, 0);

printf("test1\n");
fflush(stdout);

printf("test2\n");
sleep(5);

printf("test3\n");
fflush(stdout);

sleep(5);

pthread_kill(logger_tid,SIGKILL);
fprintf(stderr,"done\n");
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]