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 7665557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:35:59+00:00 2026-05-31T14:35:59+00:00

how do I intercept calls made from other process which I have called from

  • 0

how do I intercept calls made from other process which I have called from my process. (say – I call make and I would like to intercept and modify call to gcc from make).

  • 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-05-31T14:36:01+00:00Added an answer on May 31, 2026 at 2:36 pm

    Here is a small example with ptrace:

    #include <unistd.h>
    #include <sys/ptrace.h>
    #include <sys/types.h>
    #include <sys/wait.h>
    #include <stdio.h>
    #include <sys/user.h>
    #include <sys/prctl.h>
    
    const char *sys_call_name(long num);
    
    int main()
    {
      pid_t pid = fork();
      struct user_regs_struct regs;
      if (!pid) { 
        /* child */
        while (1) { printf("C\n"); sleep(1); }
      }
      else { /* parent */
        int status = 0;
        ptrace(PTRACE_ATTACH, pid, NULL, 0); 
        ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_SYSCALL) ;
        while (1) {
          printf("waiting\n");
          pid = wait(&status);
          /* child gone */
          //if (WIFEXITED(status)) { break; }
          ptrace(PTRACE_GETREGS, pid, 0, &regs);
          /* regs.orig_eax is the system call number */
          printf("A system call: %d : %s\n", regs.orig_eax, sys_call_name(regs.orig_eax));
          /* let child continue */
          ptrace(PTRACE_SYSCALL, pid, NULL, 0); 
        }   
      }
      return 0;
    }
    
    
    const char *sys_call_name(long num) {
      switch(num) {
        case   4: return "write";
        case 162: return "nanosleep";
        case 165: return "getresuid";
        case 174: return "rt_sigaction";
        case 175: return "rt_sigprocmask";
        default:  return "unknown";
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to intercept calls made to a database. Right now I have
I have a site which is built in ASP.net and C#. Let's call it
The following ajax call, made from a checkbox, somehow fails in Internet explorer, while
We have a Database in Sybase, which we access from a Java server. Access
I need to intercept the calls to all the method calls to an Interface.
Is there a way to intercept incomming calls/SMSes (to block or unblock it) on
Can you intercept a method call in Perl, do something with the arguments, and
Can I intercept a method call in Objective-C? How? Edit: Mark Powell 's answer
I'm trying to intercept a method call (afterInsert() of a domain class) in a
Where can I intercept reads and updates for scaffolded tables? I need to make

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.