There are dozens if not hundreds of "examples" of this - any JACK client with a GUI.
But to get an idea of the basic idea, take a look in the JACK example clients and/or tools. jack_capture would be a good place to start, since it faces the problem of handing over incoming (audio) data to another thread.
And no, you are not writing "the data" to a pipe from the JACK callback. The key ideas are (a) to move the data to another thread you need to use a lock-free data structure (b) if you need to wake the other thread (i.e. because it doesn't simply wake up periodically and use whatever new data you've delivered), you need to use the *most* RT-safe method you can. There are no absolutely RT-safe methods. A semaphore (on Linux anyway) is the best, writing a byte to a pipe is the 2nd best.
You cannot make calls from the JACK callback that may block - you cannot write to disk, read from disk, take locks, etc, etc.