Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8524499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:42:13+00:00 2026-06-11T07:42:13+00:00

In my program, I have a system call ‘sendmsg()’. I want to test what

  • 0

In my program, I have a system call ‘sendmsg()’. I want to test what will happen if this system call gets interrupted. How should I do it?

int test(args) {
          -----
          /* I can use GDB and stop at this point */  
          n = sendmsg(h, send_msg, 0);
          ----
          return n; 
 }

 int test_caller(args) {
           int a, err;
           a = test(arg);
           if (a != what_i_am_expecting) {
               err = error;
               switch (err) {
                   case EINTR:
                       syslog(LOG_ERR, "I WANT TO SEE THIS LOG");
                       break;
                   default:
                }
            } else printf("Everything went well\n");
    return 0;
   } 

In this same function I have registered a signal handler as follows:

1366         struct sigaction sa;
1367         
1368         memset (&sa, '\0', sizeof(sa));
1369         sa.sa_handler = sighdl;
1370         sa.sa_flags = 0; 
1371         (void)sigaction(SIGINT, &sa, NULL);

With this handler:

1349 static void
1350 sighdl(int signo)
1351 {
1352         int i = 0;
1353         syslog(LOG_ERR, "got signal %d", signo);
1354         for (i = 0; i < 100; i++) {
1355         }
1356 }

My idea is to break in test() function before calling sendmsg(), then send sigint to pid.
But not sure with this signa;, does it go to EINTR case in test-caller.

Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:42:14+00:00Added an answer on June 11, 2026 at 7:42 am

    Usually sendmsg call is quick. So it hard to signal during it.
    But there is a way:

    Depending of protocol sendmsg will block if the queue of receiver is full.
    So, fill the queue some way, and then press CTRL+C when your program is stuck in the sendmsg call
    (CTRL-C causes SIGINT).

    Because you catch SIGINT, program will not exit. The sendmsg will return with code -1 and errno EINTR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which does a system call: latex somefile.latex This runs ok,
I have this simple example: using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program
I have a System.Drawing.Image in my program. The file is not on the file
I have a program which doesn't once reference System.I0, coded in vb.net, yet for
I have a program that draws some vector graphics using System.Drawing and the Graphics
I have a C# program that uses System.Data.OracleClient to access an oracle database. The
I have the following MonoTouch program: using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; using System;
We have installed RHQ monitoring system http://rhq-project.org/display/RHQ/Home . From that time our program started
I have a program I want to profile with gprof. The problem (seemingly) is
Does any operating system provide a mechanism (system call — not command line program)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.