in reply to Perl fork pid Not Correcto for Xterm Spawn
You want the shell to stick around until the xterm exits. Do so by removing the "&".
Since we don't need to keep the forked copy around since at all it does is exit (with a wrong code), use exec instead of system.
#!/usr/bin/perl my $fname = "/tmp/help.txt"; system("echo help me > $fname"); my $pid = fork(); if ($pid == 0) { exec("xterm -T hello -e tail -f $fname"); exit($! || 255); } ...
Even better: Avoid the shell and use a safer interface.
#!/usr/bin/perl ... my $pid = fork(); if ($pid == 0) { exec('xterm', '-T', 'hello', '-e', 'tail', '-f', $fname); exit($! || 255); } ...
|
|---|