Thread Mail nichtblockierend (für das Skript) versenden (26 answers)
Opened by GwenDragon at 2010-02-07 18:12

topeg
 2010-02-07 18:28
#132165 #132165
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
"fork" das Script:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$SIG{CHLD}='IGNORE';

#...

unless(fork())
{
  SIG{CHILD}='DEFAULT';
  close(STDIN);
  close(STOUT);
  close(STERR);

  open(my $mailfh, '| /usr/sbin/sendmail -t -oi ') or exit();
  print $mailfh 'From: test@example.org', "\n",
        'To: admin@example.org', "\n",
        'Subject: ERROR in blah blah', "\n",
        "\n",
        'Error occured in ThisOrThat', "\n",
        "" . localtime(time), "\n",
        '.';
  close($mailfh);

  exit();
}


EDIT: Das nötige Signalhandling hinzugefügt, damit es auch funktioniert.
Last edited: 2010-02-09 20:52:09 +0100 (CET)

View full thread Mail nichtblockierend (für das Skript) versenden