From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C893645452;
	Fri, 14 Jun 2024 01:23:43 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 3398540693;
	Fri, 14 Jun 2024 01:23:43 +0200 (CEST)
Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com
 [209.85.214.172])
 by mails.dpdk.org (Postfix) with ESMTP id 3527E40274
 for <dev@dpdk.org>; Fri, 14 Jun 2024 01:23:42 +0200 (CEST)
Received: by mail-pl1-f172.google.com with SMTP id
 d9443c01a7336-1f70c457823so13518045ad.3
 for <dev@dpdk.org>; Thu, 13 Jun 2024 16:23:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1718321021;
 x=1718925821; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Zpqolwmwwyc5sCVIviB7Tqsgglv63GhHUb1XulKLrrk=;
 b=AUtpm6PkD/cAJL9ql11wilI8MXgCjuCOCgRayKpzWsebjFAvujK2aNFzHboh5eQ3SP
 /D4qJvPoKg9izPQac2KhvMtthGmJkffN4XZ1LGumqyk5AtyVCXa6rWujoZWO2SVg+VcV
 kJ/lhUttqKQ2d2xVz8mwex0FVlVpi+5I6y7Kxc7VIZpfzKtvkYrJ1PVd+CKO3T3OT2xt
 SRl2XjEZxVBrsGkFWJBdayeVuVT8x1GyRQP576r0EhT6oS5heOhZwkhPlTho4tcaRtwx
 tY778HS4HFBs1xNZeQq5EnzsvOODfTGAea4ISGAEYJm2y5Qd0hdpVWhZgEXZ6i0VwJyD
 HT4A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1718321021; x=1718925821;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Zpqolwmwwyc5sCVIviB7Tqsgglv63GhHUb1XulKLrrk=;
 b=HT6UXtfrpzVm/JwRRIgoin/fYDotZqIyXZedkREQ1EGGq5ZjIdnfvZGZQkvcjBL1yB
 ioIjkewGWNOrGX0Yha+uU0YjjBGYSt2XonUGnw2On8r0MzTXZZm5wuu7ufE9Y6SCOwX2
 vggALwYBiQVyMFlx/LF1cC3NxFitQ/H76TRsH3BGnTn0dEJMbjEFyFfWUn03w138E6bs
 hzfK3gCs6DicV9UhGeHJz0/vqYVkxmeMjl3RCT/wX2Wn1cuJppogYYX/2yT7YxUowpws
 ZtGFeyaPzqLZ8KnqjbvZz4VS94qloq3CZNSkRpyo1g5NcgKdBo614D42MR9Qvs417BSy
 1IVA==
X-Gm-Message-State: AOJu0YzT+QgM8r3Tp6K3gHpKcIby4E0ObN+y6ax/ghtRyKg9TdtuoSR/
 HeXzuP/l+KndUC/HI5V+kICMm8eN/JXFeA2n714ow/shrJbXp6DtKtEp/5pa4pU=
X-Google-Smtp-Source: AGHT+IEZnDUQhreVTxPMDLy3fhGtvI7oE6IAv2tqySjcQ+Rq4xjZ9xVcpnNfakgMHxNWTU8uEhLerA==
X-Received: by 2002:a17:902:d507:b0:1f7:1aff:679e with SMTP id
 d9443c01a7336-1f862a0aefbmr12736555ad.66.1718321021006; 
 Thu, 13 Jun 2024 16:23:41 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 d9443c01a7336-1f855e55e77sm19848215ad.12.2024.06.13.16.23.40
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 13 Jun 2024 16:23:40 -0700 (PDT)
Date: Thu, 13 Jun 2024 16:23:38 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: Kaisen You <kaisenx.you@intel.com>
Cc: dev@dpdk.org, qiming.yang@intel.com, yidingx.zhou@intel.com,
 stable@dpdk.org
Subject: Re: [PATCH] child process synchronization NIC startup parameters
Message-ID: <20240613162338.3c9f4be4@hermes.local>
In-Reply-To: <20230705093515.3285574-1-kaisenx.you@intel.com>
References: <20230705093515.3285574-1-kaisenx.you@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Wed,  5 Jul 2023 17:35:14 +0800
Kaisen You <kaisenx.you@intel.com> wrote:

>  
> +/* get cmdline form PID. Read process info form /proc/$PID. */
> +static char *get_cmdline_from_pid(pid_t pid, char *buf, int len)
> +{
> +	char filename[PATH_MAX];
> +	char *name = NULL;
> +	int fd;
> +	int ret;
> +
> +	if (pid < 1 || buf == NULL || len < 0) {
> +		printf("%s: illegal param\n", __func__);
> +		return NULL;
> +	}
> +
> +	snprintf(filename, PATH_MAX, "/proc/%d/cmdline", pid);
> +	memset(buf, 0, len);
> +	fd = open(filename, O_RDONLY);
> +	if (fd < 0) {
> +		perror("open:");
> +		return NULL;
> +	}
> +	ret = read(fd, buf, len);
> +	close(fd);
> +
> +	if (ret < 0)
> +		return NULL;
> +
> +	if (buf[ret-1] == '\n')
> +		buf[--ret] = 0;
> +
> +	name = buf;
> +	while (ret) {
> +		if (((unsigned char)*name) < ' ')
> +			*name = ' ';
> +		name++;
> +		ret--;
> +	}
> +	*name = 0;
> +
> +	if (buf[0])
> +		return buf;
> +
> +	return NULL;
> +}

Bad idea, this is not portable, and easily broken by system changes and container
environments. Please use some form of explicit communication like is done
for primary / secondary process support.