Commit 41465fb
Crystian Leão
Add open_proctitle option to filter which processes open the TCP debug port
Introduces RUBY_DEBUG_OPEN_PROCTITLE / --open-proctitle=PROCTITLE.
When set, UI_TcpServer#accept compares the value against $0 in each
process. If it matches, the TCP listening port is opened normally;
if it does not, accept() returns silently without opening a port
(and without affecting the rest of the debugger session).
The value can be either form:
- "foo" => exact-match string (compared with ==)
- "/foo/i" => regexp (parsed from /pattern/[flags])
Use case: forking job runners (e.g. solid_queue) where the supervisor
spawns several differently-named child processes. The supervisor's
startup order is non-deterministic, so --port-range from #1119 cannot
target a specific worker. With --open-proctitle='/\Asolid-queue-worker/',
only processes whose $0 matches the regexp will open a port; the
supervisor and non-matching workers run normally.
To handle the timing window between fork and Process.setproctitle in
the child, accept() waits up to 5 seconds for $0 to change from the
value captured on the first accept call (tracked in InitialProcInfo)
before evaluating the match.
The regexp form is compiled once in initialize; an invalid pattern
raises ArgumentError instead of being deferred to accept time.
The README documents that the option is intended to be used with
--nonstop (-n): without --nonstop, RUBY_DEBUG_OPEN arms an
initial-suspend breakpoint that non-matching processes would still
hit and block on. With --nonstop, no initial breakpoint is set and
non-matching processes run unaffected.
Tests cover parsing of both forms, initialize-time validation, the
match path (regexp and string), and the no-match path with --nonstop
(port not opened, program runs through).1 parent 95997c2 commit 41465fb
5 files changed
Lines changed: 326 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
375 | 420 | | |
376 | 421 | | |
377 | 422 | | |
| |||
520 | 565 | | |
521 | 566 | | |
522 | 567 | | |
| 568 | + | |
523 | 569 | | |
524 | 570 | | |
525 | 571 | | |
| |||
938 | 984 | | |
939 | 985 | | |
940 | 986 | | |
| 987 | + | |
941 | 988 | | |
942 | 989 | | |
943 | 990 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
358 | 362 | | |
359 | 363 | | |
360 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
386 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
387 | 425 | | |
388 | 426 | | |
389 | 427 | | |
390 | 428 | | |
| 429 | + | |
391 | 430 | | |
392 | 431 | | |
393 | 432 | | |
| |||
412 | 451 | | |
413 | 452 | | |
414 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
415 | 461 | | |
416 | 462 | | |
417 | 463 | | |
| |||
426 | 472 | | |
427 | 473 | | |
428 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
429 | 496 | | |
430 | 497 | | |
431 | 498 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
375 | 420 | | |
376 | 421 | | |
377 | 422 | | |
| |||
0 commit comments