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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:17:27+00:00 2026-06-09T12:17:27+00:00

In many script language, we have a programming method like this: First, there is

  • 0

In many script language, we have a programming method like this:

First, there is a function named func:

void func()
{
}

Second, I want to log some information when client call this function, but I don’t want to
modify the function , so i can do something like:

void (*pfunc)(void) = func;
void func()
{
    log("Someone call fund");
    pfunc();
}

After that, anyone who call fund will call my “override” function.This is OK in many script language. Can I do the same thing in C language? And how to code it?

I want to use this method to do some work in some 3party library, so I must do something affect the link process, not just the compile process.

  • 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-09T12:17:28+00:00Added an answer on June 9, 2026 at 12:17 pm

    Maybe you are looking for a library interposer. You could define your own functions in a file and call the program you want to log calls using that functions instead of the syscalls.

    For example, interposing some syscalls made by ls:

    $ LD_PRELOAD=/your/own/functions/file.so ls -l
    

    It is better suited for situations where you can’t change the program code (maybe because it is unavailable) that is calling the functions you want to log.

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

Sidebar

Related Questions

I have many lines in my script that look like: ./run -f abc.txt ./run
I have a sed(1) script doing many step-by-step transformations (substitutions) of a given input
I have written a Python script for merging many data files in a few
I have a simple script to check how many files a user has uploaded:
I have a script language based on Antlr: A parser and a tree grammar
We have an R Server (R is a programming language used in statistical analysis)
I understand that this question is based on a very old programming language, and
how are you guys? I'm trying to make my PHP script accept many languages,
I am trying to change my many to many script field to use FilteredSelectMultiple
I've tried my best to find out a solution with the many script questions

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.