是OS内核或进程生成的信号吗?

时间:2015-12-15 01:15:34

标签: operating-system signals ipc

https://en.wikipedia.org/wiki/Unix_signal

  

信号是一种有限形式的进程间通信   Unix,类Unix和其他符合POSIX标准的操作系统。一个信号   是发送到进程或特定进程的异步通知   同一进程中的线程,以便通知它一个事件   发生了。

     

...

     

内核可以生成信号以通知事件的进程。对于   例如,当进程写入管道时将生成SIGPIPE   被读者关闭;默认情况下,这会导致   进程终止,这在构造shell时很方便   管道

是OS内核或进程生成的信号吗?

如果OS内核生成信号,那么在进程间通信中如何使用信号?是通过在通信中的两个进程之间使用OS内核来完成的,即进程通过某种方式与OS内核通信(也是信号?),然后OS内核通过信号与另一进程通信?

1 个答案:

答案 0 :(得分:1)

信号可以由内核或其他进程发起。在您的示例中,内核生成信号本身,以便与进程进行通信。

其他进程也可以使用kill(2)发送信号,要求内核向进程或进程组发送信号(进程甚至可以向自身发送信号)。如果发起者有权发送信号,则内核会发送信号。

当运行类似:

之类的操作时会发生这种情况
    using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.DirectoryServices.AccountManagement;
using System.IO;

//
//  Todo :
//      -- Capture Assigned Team In Output
//
//

namespace CallsAnalysisToolbox
{
    public partial class ContactAnalysisToolbox : Form
    {
        public ContactAnalysisToolbox()
        {
            InitializeComponent();

            // Grabs username for current user and displays a welcome message
            this.welcomeMessage.Text = "Welcome " + UserPrincipal.Current.Name;
        }

        private void searchVision_Click(object sender, EventArgs e)
        {
            try
            {
                // Run sp_incomingCalls on SQLCLUSTER
                this.rep_IncomingCallsTableAdapter.Fill(this.visionReportsDataSet.Rep_IncomingCalls, dateTimePicker1.Value, dateTimePicker2.Value, textBox1.Text, textBox2.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

            // Make export button active when search returns results
            exportVisionButton.Enabled = (visionDataGridView.Rows.Count > 0);

            // Assign returned row count to visionSearchResultCount label and then display label
            visionSearchResultCount.Text = String.Format("Your search returned {0} results", visionDataGridView.RowCount);
            visionSearchResultCount.Visible = true;
        }

        private void searchDesk_Click(object sender, EventArgs e)
        {
            try
            {
                // Run sp_caseActivity on SQLCLUSTER
                this.rPT_CaseActivityTableAdapter.Fill(this.deskDataSet.RPT_CaseActivity, deskFrom.Value, deskTo.Value, deskClientList.Text, deskBenefitList.Text, deskStatusList.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

            if (deskDataGridView.Rows.Count > 0)
            {


                exportDeskButton.Enabled = true;
                deskSearchResultCount.Visible = true;

                Summary Returned = new Summary();

                deskSearchResultCount.Text = String.Format("Your search returned {0} results", Returned.Total("Desk"));

                deskSummaryData.Visible = true;
                noDataDesk.Visible = false;

                // Populate the summary tab

                // Get Email / Phone case count


                deskTotalCaseResults.Text = deskDataGridView.RowCount.ToString();
                //deskTotalEmailCasesResults.Text = emailCount.ToString();
                //deskTotalPhoneCasesResults.Text = phoneCount.ToString();
            }
        }

        //TODO : Combine Export functions. Ideally just a single function rather than the repeated logic within the Export class for each datagrid
        private void exportVisionButton_Click(object sender, EventArgs e)
        {
            Export Export = new Export();

            Export.ReturnedResult("Vision");
        }

        private void exportDeskButton_Click(object sender, EventArgs e)
        {
            Export Export = new Export();

            Export.ReturnedResult("Desk");
        }

        private void deskDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // Limit 'open case in browser' action to first cell
            if (deskDataGridView.CurrentCell.ColumnIndex.Equals(0))
            {
                string url = string.Format("https://qa.internal.local/agent/case/{0}", deskDataGridView.Rows[e.RowIndex].Cells[0].Value);
                Process.Start(url);
            }
        }
    }
}

值得注意的是,内核是唯一能够传递信号的实体,无论其来源如何。