You'd need to ask the shell process to tell it to you. Could be done with gdb for instance.
$ ps -fH
UID PID PPID C STIME TTY TIME CMD
chazelas 5148 5145 0 17:31 pts/2 00:00:00 /bin/zsh
chazelas 8142 5148 0 17:49 pts/2 00:00:00 bash -c (sleep 1h; echo A) & (sleep 1h; echo B) & sleep 1h
chazelas 8143 8142 0 17:49 pts/2 00:00:00 bash -c (sleep 1h; echo A) & (sleep 1h; echo B) & sleep 1h
chazelas 8145 8143 0 17:49 pts/2 00:00:00 sleep 1h
chazelas 8144 8142 0 17:49 pts/2 00:00:00 bash -c (sleep 1h; echo A) & (sleep 1h; echo B) & sleep 1h
chazelas 8147 8144 0 17:49 pts/2 00:00:00 sleep 1h
chazelas 8146 8142 0 17:49 pts/2 00:00:00 sleep 1h
chazelas 8503 5148 0 17:50 pts/2 00:00:00 ps -fH
$ gdb --pid 8143 =bash
[...]
(gdb) bt
#0 0x00007fee157668d3 in __GI___wait4 (pid=pid@entry=-1, stat_loc=stat_loc@entry=0x7ffd395961b0, options=options@entry=0, usage=usage@entry=0x0) at ../sysdeps/unix/sysv/linux/wait4.c:30
#1 0x00007fee15766a27 in __GI___waitpid (pid=pid@entry=-1, stat_loc=stat_loc@entry=0x7ffd395961b0, options=options@entry=0) at ./posix/waitpid.c:38
#2 0x0000561fe33573a2 in waitchld (block=block@entry=1, wpid=8145) at .././jobs.c:3805
#3 0x0000561fe3358b9a in wait_for (pid=8145, flags=flags@entry=0) at .././jobs.c:2980
#4 0x0000561fe334422b in execute_command_internal (command=command@entry=0x561ff269de90, asynchronous=asynchronous@entry=0, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e6d0) at .././execute_cmd.c:911
#5 0x0000561fe33443d9 in execute_command (command=0x561ff269de90) at .././execute_cmd.c:413
#6 0x0000561fe3346307 in execute_connection (command=0x561ff269e060, asynchronous=0, pipe_in=-1, pipe_out=-1, fds_to_close=0x561ff269e580) at .././execute_cmd.c:2757
#7 0x0000561fe3340ec4 in execute_command_internal (command=command@entry=0x561ff269e060, asynchronous=asynchronous@entry=0, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e580) at .././execute_cmd.c:1040
#8 0x0000561fe33449e8 in execute_in_subshell (command=0x561ff269e0b0, asynchronous=0, asynchronous@entry=1, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e580) at .././execute_cmd.c:1721
#9 0x0000561fe3340a11 in execute_command_internal (command=command@entry=0x561ff269e0b0, asynchronous=asynchronous@entry=1, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e580) at .././execute_cmd.c:678
#10 0x0000561fe334624f in execute_connection (command=0x561ff269e3e0, asynchronous=1, pipe_in=-1, pipe_out=-1, fds_to_close=0x561ff269e580) at .././execute_cmd.c:2726
#11 0x0000561fe3340ec4 in execute_command_internal (command=command@entry=0x561ff269e3e0, asynchronous=asynchronous@entry=1, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e580) at .././execute_cmd.c:1040
#12 0x0000561fe334624f in execute_connection (command=0x561ff269e550, asynchronous=0, pipe_in=-1, pipe_out=-1, fds_to_close=0x561ff269e580) at .././execute_cmd.c:2726
#13 0x0000561fe3340ec4 in execute_command_internal (command=<optimized out>, asynchronous=asynchronous@entry=0, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e580) at .././execute_cmd.c:1040
#14 0x0000561fe339e189 in parse_and_execute (string=<optimized out>, from_file=from_file@entry=0x561fe33f00a4 "-c", flags=flags@entry=20) at ../.././builtins/evalstring.c:539
#15 0x0000561fe3328fda in run_one_command (command=0x7ffd39598d99 "(sleep 1h; echo A) & (sleep 1h; echo B) & sleep 1h") at .././shell.c:1473
#16 0x0000561fe3327aa2 in main (argc=3, argv=0x7ffd39596db8, env=0x7ffd39596dd8) at .././shell.c:763
(gdb) frame 8
#8 0x0000561fe33449e8 in execute_in_subshell (command=0x561ff269e0b0, asynchronous=0, asynchronous@entry=1, pipe_in=pipe_in@entry=-1, pipe_out=pipe_out@entry=-1,
fds_to_close=fds_to_close@entry=0x561ff269e580) at .././execute_cmd.c:1721
1721 in .././execute_cmd.c
(gdb) p make_command_string(command)
$1 = 0x561ff269e680 "( sleep 1h; echo A )"
(gdb) detach
Detaching from program: /usr/bin/bash, process 8143
[Inferior 1 (process 8143) detached]
(gdb) exit
That process is running the subshell that will eventually run echo A.
some_command? Could you replace it with a wrapper script that somehow notifies your other script? Or is there some expected result ofsome_commandlike a modified file? What is the purpose of the delayed execution? This seems to be a strange approach.some_commandis one of the scripts you don't want to modify. It might be possible to use wrapper scripts without modifying the existing files by placing the replacements into a directory that comes first inPATH, e.g./usr/local/bin/some_commandas a wrapper for/usr/bin/some_commandassuming that/usr/local/binprecedes/usr/bin.