HI
I would like to pass new argument to cureently running process with out interuption in unix using c code


can any one Idea on this

Please suggest

Thanks in Advance
Madan

Dani AI

Generated

was right that a signal is the usual trigger, but a signal alone only notifies a process — it does not carry arbitrary text arguments. The robust pattern is to have the running program cooperate: use a signal to tell the process "read new input now", and then deliver the actual argument(s) through a control channel (file, FIFO, Unix-domain socket) or, for small numeric values, via sigqueue. This avoids restarting the process and keeps handling deterministic. See the signal overview for behavior details (signal(7)).

A minimal, safe workflow:

  1. Modify the program to install a handler (use sigaction with SA_SIGINFO or use signalfd to handle signals synchronously).
  2. In the handler set a volatile sig_atomic_t flag (or read the queued value from siginfo_t if using sigqueue) and return quickly.
  3. In the main loop, when the flag is seen, read the new argument(s) from a known place (e.g., /var/run/app.cmd or a FIFO/Unix socket) and apply them.

Example handler sketch:

static void on_sig(int sig, siginfo_t *si, void *u) {
    pending = 1;               /* sig_atomic_t flag */
    queued = si ? si->si_value.sival_int : 0;
}

/* install with sigaction(SA_SIGINFO) */

For small additional data, sigqueue can attach a small integer (sigqueue(3)). For richer commands use a FIFO or Unix socket (fifo(7), unix(7)). Avoid doing heavy work in a signal handler and validate all inputs to avoid security/race issues.

Recommended Answers

All 3 Replies

Can you please elaborate.... I didn't get you actually...

HI Thanks it i sworking fine

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.