From: Rommer <rommer@active.by>
To: linux-kernel@vger.kernel.org
Subject: PROBLEM: fork() & setpriority()
Date: Mon, 11 Jul 2005 13:58:09 +0300 [thread overview]
Message-ID: <42D250C1.6070604@active.by> (raw)
[-- Attachment #1: Type: text/plain, Size: 204 bytes --]
Hello,
I have trouble with fork() and setpriority().
When priority of child process != priority of parent process
and used SIGCHLD handler.
See example.
kernel 2.6.12.1, no SMP
--
Best regards, Roman
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 739 bytes --]
#include <sys/time.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
struct sigaction sa_chld;
int i = 0;
static void chld_handler (int signum) {
int status = 0;
wait (&status);
printf ("child closed: status = %i\n", status >> 8);
}
void test (void) {
pid_t pid = fork ();
if (pid == 0) {
setpriority (PRIO_PROCESS, 0, 0);
printf ("helo from child, i = %i\n", i);
exit (i);
}
}
int main () {
memset (&sa_chld, 0, sizeof (sa_chld));
sa_chld.sa_handler = &chld_handler;
sigaction (SIGCHLD, &sa_chld, NULL);
setpriority (PRIO_PROCESS, 0, -1);
while (1) {
i++;
test ();
sleep (3);
}
return 0;
}
next reply other threads:[~2005-07-11 10:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-11 10:58 Rommer [this message]
2005-07-11 11:07 ` PROBLEM: fork() & setpriority() Arjan van de Ven
2005-07-11 11:14 ` Rommer
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=42D250C1.6070604@active.by \
--to=rommer@active.by \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.