From: Artem <u2u@nm.ru>
To: ALT Linux Sisyphus discussion list <sisyphus@lists.altlinux.org>
Subject: [sisyphus] создание демона, перенаправление stderr и initlog
Date: Sun, 20 Nov 2005 22:31:07 +0200
Message-ID: <4380DD0B.9050400@nm.ru> (raw)
Доброго времени суток!
Не знаю - это в Сизифе так - или нет (под рукой других дистрибутивов
нет). Имелась программа, выводившая в процессе работы некую отладочную и
просто - информацию о работе. Добавил в нее функционал работы в режиме
демона (fork + setsid). При запуске в консоли - все ок, сообщения о ходе
работы "выплевывались" на консоль. Сделал скрипт в init.d, стартую -
через пару секунд работы программа безследно умирает. Заметил, что
скорость "умирания" зависела от количества выводимой ею информации. Так
же обратил внимание, что запуск с помощью стартап-скриптов идет через
initlog -c "команда" .
if (make_daemon) {
switch (pid=fork()) {
case 0:
setsid();
write_pidfile();
DBG("process pid: %d\n", getpid());
ret=program_run(<parameters>);
break;
<skip>
Все заработало нормально только тогда, когда вывод дескрипторов 0,1,2
был перенаправлен в /dev/null
Типа нижеприведенного:
if (make_daemon) {
switch (pid=fork()) {
case 0:
setsid();
write_pidfile();
DBG("process pid: %d\n", getpid());
if ((fd = open("/dev/null", O_RDWR, 0)) >= 0) {
(void) dup2(fd, 0);
(void) dup2(fd, 1);
(void) dup2(fd, 2);
if (fd != 2)
(void) close(fd);
ret=program_run(<parameters>);
break;
<skip>
Почему initlog прибивал процесс, выводящий много информации в stdout ?
Правильное ли это исправление - или есть более правильные способы
реализации?
P.S. Не знаю - может это уже вопрос для devel@ - но что-то на сайте
написано, что это - "закрытый список рассылки" ?
Rgds, Artem.
next reply other threads:[~2005-11-20 20:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-20 20:31 Artem [this message]
2005-11-20 22:52 ` Dmitry V. Levin
2005-11-21 0:03 ` Artem
2005-11-21 0:40 ` Dmitry V. Levin
2005-11-21 7:32 ` Artem
2005-11-21 7:41 ` Artem
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=4380DD0B.9050400@nm.ru \
--to=u2u@nm.ru \
--cc=sisyphus@lists.altlinux.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
ALT Linux Sisyphus discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
public-inbox-index sisyphus
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.sisyphus
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git