From: rsc@plan9.bell-labs.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] C-program error..
Date: Fri, 16 Jun 2000 15:52:46 -0400 [thread overview]
Message-ID: <200006161952.PAA05754@cse.psu.edu> (raw)
A few problems. The main one is that you
sent a 32-byte array and tried to read it
into what was pointed at by an uninitialized pointer.
Compiling with -w would catch this.
The second is that you need to use threadprint
instead of print to avoid stack problems.
Threadprint is like fprint, so you need
to give a file descriptor.
The below works for me.
Russ
#include <u.h>
#include <libc.h>
#include <thread.h>
#define STACKSIZE (2*2048)
void
recvit(void *arg)
{
char *s;
Channel *in; /* of char* */
in = arg;
s = recvp(in);
threadprint(1, "%s\n", s);
threadexits(0);
}
void
threadmain(int argc, char *argv[])
{
Channel *sch; /* of char* */
sch = chancreate(sizeof(char*), 0);
proccreate(recvit, (void *)sch, STACKSIZE);
sendp(sch, "hello world");
threadprint(1, "done\n");
threadexitsall(nil);
}
next reply other threads:[~2000-06-16 19:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-16 19:52 rsc [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-06-16 19:50 dhog
2000-06-16 18:57 Ish Rattan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200006161952.PAA05754@cse.psu.edu \
--to=rsc@plan9.bell-labs.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).