<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; Помогите разобраться с сигналами]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=9109&amp;type=atom" />
	<updated>2010-12-12T13:06:08Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=9109</id>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121500#p121500" />
			<content type="html"><![CDATA[<p>Спасибо за терпение и за помощь)<br />Почти все понял, остался один маленький вопрос)<br />Сигналы через kill надо вручную посылать, потому что некоторые будут убивать процесс, и надо его запускать заного (с новым pid). Это верно?</p>]]></content>
			<author>
				<name><![CDATA[NegativeCreep]]></name>
				<uri>https://linuxforum.ru/profile.php?id=13578</uri>
			</author>
			<updated>2010-12-12T13:06:08Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121500#p121500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121363#p121363" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>if(i!=SIGSTOP&amp;&amp;i!= SIGKILL)</p></blockquote></div><p>довольно глупо, ибо насколько я знаю, SIGKILL никогда не доходит до программы.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-12-12T02:19:29Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121363#p121363</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121362#p121362" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>Мне же нужно, чтобы это были названия сигналов(типа SIGSTOP, SIGKILL).</p></blockquote></div><p>добавьте в вашу программу<br /></p><div class="codebox"><pre><code>#include &lt;signal.h&gt;</code></pre></div><p>это приведёт к добавлению такого файла (далее для моей системы, в вашей файл может быть другим и с другим именем!)<br />doc@dt:~$ cat !$<br /></p><div class="codebox"><pre><code>cat /usr/include/bits/signum.h
/* Signal number definitions.  Linux version.
   Copyright (C) 1995,1996,1997,1998,1999,2003 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#ifdef    _SIGNAL_H

/* Fake signal functions.  */
#define SIG_ERR    ((__sighandler_t) -1)        /* Error return.  */
#define SIG_DFL    ((__sighandler_t) 0)        /* Default action.  */
#define SIG_IGN    ((__sighandler_t) 1)        /* Ignore signal.  */

#ifdef __USE_UNIX98
# define SIG_HOLD    ((__sighandler_t) 2)    /* Add signal to hold mask.  */
#endif


/* Signals.  */
#define    SIGHUP        1    /* Hangup (POSIX).  */
#define    SIGINT        2    /* Interrupt (ANSI).  */
#define    SIGQUIT        3    /* Quit (POSIX).  */
#define    SIGILL        4    /* Illegal instruction (ANSI).  */
#define    SIGTRAP        5    /* Trace trap (POSIX).  */
#define    SIGABRT        6    /* Abort (ANSI).  */
#define    SIGIOT        6    /* IOT trap (4.2 BSD).  */
#define    SIGBUS        7    /* BUS error (4.2 BSD).  */
#define    SIGFPE        8    /* Floating-point exception (ANSI).  */
#define    SIGKILL        9    /* Kill, unblockable (POSIX).  */
#define    SIGUSR1        10    /* User-defined signal 1 (POSIX).  */
#define    SIGSEGV        11    /* Segmentation violation (ANSI).  */
#define    SIGUSR2        12    /* User-defined signal 2 (POSIX).  */
#define    SIGPIPE        13    /* Broken pipe (POSIX).  */
#define    SIGALRM        14    /* Alarm clock (POSIX).  */
#define    SIGTERM        15    /* Termination (ANSI).  */
#define    SIGSTKFLT    16    /* Stack fault.  */
#define    SIGCLD        SIGCHLD    /* Same as SIGCHLD (System V).  */
#define    SIGCHLD        17    /* Child status has changed (POSIX).  */
#define    SIGCONT        18    /* Continue (POSIX).  */
#define    SIGSTOP        19    /* Stop, unblockable (POSIX).  */
#define    SIGTSTP        20    /* Keyboard stop (POSIX).  */
#define    SIGTTIN        21    /* Background read from tty (POSIX).  */
#define    SIGTTOU        22    /* Background write to tty (POSIX).  */
#define    SIGURG        23    /* Urgent condition on socket (4.2 BSD).  */
#define    SIGXCPU        24    /* CPU limit exceeded (4.2 BSD).  */
#define    SIGXFSZ        25    /* File size limit exceeded (4.2 BSD).  */
#define    SIGVTALRM    26    /* Virtual alarm clock (4.2 BSD).  */
#define    SIGPROF        27    /* Profiling alarm clock (4.2 BSD).  */
#define    SIGWINCH    28    /* Window size change (4.3 BSD, Sun).  */
#define    SIGPOLL        SIGIO    /* Pollable event occurred (System V).  */
#define    SIGIO        29    /* I/O now possible (4.2 BSD).  */
#define    SIGPWR        30    /* Power failure restart (System V).  */
#define SIGSYS        31    /* Bad system call.  */
#define SIGUNUSED    31

#define    _NSIG        65    /* Biggest signal number + 1
                   (including real-time signals).  */

#define SIGRTMIN        (__libc_current_sigrtmin ())
#define SIGRTMAX        (__libc_current_sigrtmax ())

/* These are the hard limits of the kernel.  These values should not be
   used directly at user level.  */
#define __SIGRTMIN    32
#define __SIGRTMAX    (_NSIG - 1)

#endif    /* &lt;signal.h&gt; included.  */</code></pre></div>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-12-12T02:16:04Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121362#p121362</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121360#p121360" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>1)Извиняюсь, торопился. В пером было &quot;Процесс пользователя А может посылать любые сигналы процессу пользователя А&quot;.<br />2)Насчет второго - такой вывод сделал на основании того, что kill(pid,signal) возвращала -1(pid - пид любого процесса пользователя Б).</p></blockquote></div><p>1) куда спешить-то?<br />2) да. насколько я знаю, только процесс с UID == 0 может посылать сообщения другим процессам. Это связанно с безопасностью (например на сервере одни пользователи не имеют права вырубать программы других. Ибо анархия == wendowz.) Только администратор может управлять процессами пользователей. Я знаю, это не очень удобно - приходится делать например сигнальные файлы для обмена информацией.<br /></p><div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>где мы определяем переменную status</p></blockquote></div><p>в самом начале. потом адрес этой переменной передаётся внутрь waitpid(), которая и пишет туда текущий статус.<br /></p><div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>Как я понимаю, нужно запустить эту программу, а затем посылать ей сигналы с другой.</p></blockquote></div><p>ага. А программа, которая посылает сигналы называется <strong>kill</strong>. По умолчанию она посылает сигнал TERM, который завершает программу, но можно послать и любой другой сигнал любой программе.</p><p>Имеется исключение: сигнал KILL передаётся не программе, а ядру, которое завершает заданный процесс. например:<br /><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh">doc@dt:~$ sleep 1h &amp;<br />[1] 2368<br />doc@dt:~$ kill -KILL 2368<br />doc@dt:~$ kill -KILL 2368<br />bash: kill: (2368) - Нет такого процесса<br />[1]+&nbsp; Убито&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sleep 1h<br />doc@dt:~$ <br /></div><br />тут я запустил программу sleep, с параметром &quot;1 час&quot;. А потом грохнул её, послав сигнал KILL (это девятка).</p><div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>Вид исходного кода исправил.</p></blockquote></div><p>спасибо.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-12-12T02:05:34Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121360#p121360</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121355#p121355" />
			<content type="html"><![CDATA[<p>Вид исходного кода исправил.</p>]]></content>
			<author>
				<name><![CDATA[NegativeCreep]]></name>
				<uri>https://linuxforum.ru/profile.php?id=13578</uri>
			</author>
			<updated>2010-12-12T01:08:15Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121355#p121355</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121353#p121353" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>drBatty пишет:</cite><blockquote><div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>Пожалуйста, подскажите тогда верно ли следующее:<br />1)Процесс пользователя А может посылать любые сигналы процессу пользователя В<br />2)Процесс пользователя А не может посылать процессу пользователя B никаких сигналов, даже если они члены одной группы<br />Ну и тем более процессу пользователя root</p></blockquote></div><p>1) да<br />2) ничегонипонял. сформулируйте по человечески.</p></blockquote></div><p>Извиняюсь, торопился. В пером было &quot;Процесс пользователя А может посылать любые сигналы процессу пользователя А&quot;.<br />Насчет второго - такой вывод сделал на основании того, что kill(pid,signal) возвращала -1(pid - пид любого процесса пользователя Б).</p><div class="quotebox"><cite>drBatty пишет:</cite><blockquote><p>#include &lt;sys/wait.h&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;stdlib.h&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;unistd.h&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;stdio.h&gt;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;int<br />&nbsp; &nbsp; &nbsp; &nbsp;main(int argc, char *argv[])<br />&nbsp; &nbsp; &nbsp; &nbsp;{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pid_t cpid, w;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;int status;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cpid = fork();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (cpid == -1) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;fork&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (cpid == 0) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Code executed by child */<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;Child PID is %ld\n&quot;, (long) getpid());<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (argc == 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pause();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Wait for signals */<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;_exit(atoi(argv[1]));</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Code executed by parent */<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;do {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;w = waitpid(cpid, &amp;status, WUNTRACED | WCONTINUED);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (w == -1) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;perror(&quot;waitpid&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_FAILURE);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (WIFEXITED(status)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;exited, status=%d\n&quot;, WEXITSTATUS(status));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else if (WIFSIGNALED(status)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;killed by signal %d\n&quot;, WTERMSIG(status));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else if (WIFSTOPPED(status)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;stopped by signal %d\n&quot;, WSTOPSIG(status));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} else if (WIFCONTINUED(status)) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;continued\n&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} while (!WIFEXITED(status) &amp;&amp; !WIFSIGNALED(status));<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;exit(EXIT_SUCCESS);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />&nbsp; &nbsp; &nbsp; &nbsp;}</p><p>PS: ну маны читать нынче не модно sad</p></blockquote></div><p>За программу огромное спасибо, все понятно кроме того, где мы определяем переменную status. man wait изучал, использовать его не догадался(.<br />Как я понимаю, нужно запустить эту программу, а затем посылать ей сигналы с другой.</p>]]></content>
			<author>
				<name><![CDATA[NegativeCreep]]></name>
				<uri>https://linuxforum.ru/profile.php?id=13578</uri>
			</author>
			<updated>2010-12-12T01:06:32Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121353#p121353</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121351#p121351" />
			<content type="html"><![CDATA[<p><strong>man wait</strong></p><br /><br /><div class="codebox"><pre><code>       #include &lt;sys/wait.h&gt;
       #include &lt;stdlib.h&gt;
       #include &lt;unistd.h&gt;
       #include &lt;stdio.h&gt;

       int
       main(int argc, char *argv[])
       {
           pid_t cpid, w;
           int status;

           cpid = fork();
           if (cpid == -1) {
               perror(&quot;fork&quot;);
               exit(EXIT_FAILURE);
           }

           if (cpid == 0) {            /* Code executed by child */
               printf(&quot;Child PID is %ld\n&quot;, (long) getpid());
               if (argc == 1)
                   pause();                    /* Wait for signals */
               _exit(atoi(argv[1]));

           } else {                    /* Code executed by parent */
               do {
                   w = waitpid(cpid, &amp;status, WUNTRACED | WCONTINUED);
                   if (w == -1) {
                       perror(&quot;waitpid&quot;);
                       exit(EXIT_FAILURE);
                   }

                   if (WIFEXITED(status)) {
                       printf(&quot;exited, status=%d\n&quot;, WEXITSTATUS(status));
                   } else if (WIFSIGNALED(status)) {
                       printf(&quot;killed by signal %d\n&quot;, WTERMSIG(status));
                   } else if (WIFSTOPPED(status)) {
                       printf(&quot;stopped by signal %d\n&quot;, WSTOPSIG(status));
                   } else if (WIFCONTINUED(status)) {
                       printf(&quot;continued\n&quot;);
                   }
               } while (!WIFEXITED(status) &amp;&amp; !WIFSIGNALED(status));
               exit(EXIT_SUCCESS);
           }
       }</code></pre></div><p>PS: ну маны читать нынче не модно <img src="https://linuxforum.ru/img/smilies/ac.gif" alt="ac" /></p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-12-12T00:36:19Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121351#p121351</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121349#p121349" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>NegativeCreep пишет:</cite><blockquote><p>Пожалуйста, подскажите тогда верно ли следующее:<br />1)Процесс пользователя А может посылать любые сигналы процессу пользователя В<br />2)Процесс пользователя А не может посылать процессу пользователя B никаких сигналов, даже если они члены одной группы<br />Ну и тем более процессу пользователя root</p></blockquote></div><p>1) да<br />2) ничегонипонял. сформулируйте по человечески.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2010-12-12T00:30:06Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121349#p121349</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121333#p121333" />
			<content type="html"><![CDATA[<p>Так, вроде получил желаемый результат)</p><p>Пожалуйста, подскажите тогда верно ли следующее:<br />Процесс пользователя А может посылать любые сигналы процессу пользователя В<br />Процесс пользователя А не может посылать процессу пользователя B никаких сигналов, даже если они члены одной группы<br />Ну и тем более процессу пользователя root</p>]]></content>
			<author>
				<name><![CDATA[NegativeCreep]]></name>
				<uri>https://linuxforum.ru/profile.php?id=13578</uri>
			</author>
			<updated>2010-12-11T22:27:41Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121333#p121333</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Помогите разобраться с сигналами]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=121306#p121306" />
			<content type="html"><![CDATA[<p>Имею такое задание:<br />Написать программу trykill которая на практике определяет множество сигналов,<br />- которыми могут обмениваться 2 процесса одного пользователя;<br />- которые могут быть посланы процессом пользователя A процессу пользователя B, при условии, что пользователи A и B являются членами одной группы;<br />- которые могут быть посланы процессом пользователя A процессу пользователя root.</p><p>Честно, не совсем представляю себе, как это решать. Нашел в интернете такую программу:<br /></p><div class="codebox"><pre><code>void sig_handler(int sig)
{
    printf(&quot;cathed signal %d\n&quot;,sig);
    exit(0);
}
int main(int argc,char **argv[])
{
    int i,errno,err;
    pid_t pid;
    // пока он спит, тестим его на восприимчивость сигналов
    for(i = 1;i &lt; NSIG;i++)
    {
        if(i!=SIGSTOP&amp;&amp;i!= SIGKILL)
        {
            errno=0;
            err=signal(i, sig_handler);
            printf(&quot;sig %d, status %d, errno %d\n&quot;,i,err,errno);
        }
    }
    if((pid=fork())==0)
    {
        execl(&quot;./launch&quot;,&quot;./launch&quot;,0);
        sleep(30);
    }
}</code></pre></div><p>В случае, когда надо послать сигнал другому пользователю:</p><div class="codebox"><pre><code>void sig_handler(int sig)
{
    exit(0);
}
int main(int argc,char **argv[])
{
    int i,errno,err;
    pid_t pid;
    for(i = 1;i &lt;NSIG;i++)
    {
        if(i!=SIGSTOP&amp;&amp;i!= SIGKILL)
        {
            err=kill(ЗДЕСЬ PID ПРОЦЕССА ДРУГОГО ПОЛЬЗОВАТЕЛЯ, i);
            printf(&quot;sig %d, status %d\n&quot;,i,err);
        }
    }
    if((pid=fork())==0)
    {
        execl(&quot;./launch&quot;,&quot;./launch&quot;,0);
        sleep(30);
    }
}</code></pre></div><p>Как я понял, на печать выводятся сигналы, на которые отреагеровала функция sig_handler в виде цифр(по сути числа от 1 до 64). Мне же нужно, чтобы это были названия сигналов(типа SIGSTOP, SIGKILL). Первый вопрос - как сделать, чтобы выводились они.<br />Ну, это работает для процессов одного пользователя, а второй вопрос заключается в том, чтобы сделать это для двух.</p><p><span style="color: red">-</span></p>]]></content>
			<author>
				<name><![CDATA[NegativeCreep]]></name>
				<uri>https://linuxforum.ru/profile.php?id=13578</uri>
			</author>
			<updated>2010-12-11T20:48:21Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=121306#p121306</id>
		</entry>
</feed>
