linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonny Grant <jg@jguk.org>
To: Michael Kerrisk <mtk.manpages@gmail.com>,
	linux-man <linux-man@vger.kernel.org>
Subject: pthread_create
Date: Mon, 15 Jun 2020 22:40:04 +0100	[thread overview]
Message-ID: <1d9f60fa-9446-d038-f98b-c307feb0849f@jguk.org> (raw)

Hello mtk,

https://www.man7.org/linux/man-pages/man3/pthread_create.3.html

This has a good example I saw, what do you think about replacing these pre-processor macros containing do {} while(0) with regular functions?

Something like this:

void handle_error_en(int en, const char * const msg)
{
      errno = en;
      perror(msg);
      exit(EXIT_FAILURE);
}

void handle_error(const char * const msg)
{
      perror(msg);
      exit(EXIT_FAILURE);
}


Although I don't think errno is such a good idea. so I'd probably write:

void handle_error_en(int en, const char * const msg)
{
      fprintf(stderr, "%s: %s\n", msg, strerror(en));
      exit(EXIT_FAILURE);
}

I'd also suggest adding the command line to compile $ cc -Wall -pthread -o threads threads.c

Regards, Jonny

                 reply	other threads:[~2020-06-15 21:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1d9f60fa-9446-d038-f98b-c307feb0849f@jguk.org \
    --to=jg@jguk.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /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).